Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve stats "Done" channel error #23

Open
3 of 4 tasks
Cerfoglg opened this issue Nov 23, 2015 · 4 comments
Open
3 of 4 tasks

Solve stats "Done" channel error #23

Cerfoglg opened this issue Nov 23, 2015 · 4 comments

Comments

@Cerfoglg
Copy link
Contributor

Cerfoglg commented Nov 23, 2015

In the stats collector, we are using this golang API for connecting to Docker and retrieving the stats: https://github.com/fsouza/go-dockerclient

In the code, we use this function to retrieve the stats: https://godoc.org/github.com/fsouza/go-dockerclient#Client.Stats

The function is blocking, meaning that once started the routine can't be exited unless the function is stopped. It's possible to stop the function by signalling on the Done channel, which can be passed to the function inside the StatsOpts structure. Theoretically, sending a boolean to the channel should interrupt the function, however when attempting to do so an error is returned that states the channel is closed. It's possible this is an issue with the API itself.

What needs to be done:

  • Debug the program step by step, and try writing a smaller straight forward code to test the interruption of the function directly.
  • If the issue is in the API, open an issue on the GitHub of the API itself to report this problem.
  • Wait for the answer and fix the issue
  • Try if the same approach of the stopChannel works also for the doneChannel. It depends on how the library handle this channel. So: one channel for all the goroutine that gets closed when done.

Related issues: #1, #4, benchflow/monitors#1,

@VincenzoFerme VincenzoFerme added this to the 0.0.1 milestone Nov 24, 2015
@Cerfoglg
Copy link
Contributor Author

It's very likely that the API is the issue here. I've tested it in the simplest way possible, and it still gives me the error. I reported this on the github of the API: fsouza/go-dockerclient#423

@VincenzoFerme
Copy link
Member

@Cerfoglg since they are not replying lets proceed with a different approach to stop the execution of the blocking go routine. We then update this issue and keep it open waiting for the response of for future investigations by our side. Maybe here we found some hints: http://blog.labix.org/2011/10/09/death-of-goroutines-under-control

@Cerfoglg
Copy link
Contributor Author

Cerfoglg commented Dec 5, 2015

@VincenzoFerme It appears that the done channel does work in stopping the function, but the Stats function returns an error when stopped instead of quitting gracefully. It's easy to work around that, so the problem is solved now, although it would be nice to not have the function give that error when exiting. I added a comment on the API's issue I opened.

@VincenzoFerme
Copy link
Member

@Cerfoglg ok, lets wait for an answer and see if it can be improved. It seems enough for now, as solved in benchflow/monitors#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants