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

probe: Stats gathering can be started twice #1799

Closed
ekimekim opened this issue Aug 16, 2016 · 5 comments · Fixed by #1833
Closed

probe: Stats gathering can be started twice #1799

ekimekim opened this issue Aug 16, 2016 · 5 comments · Fixed by #1833
Assignees
Labels
bug Broken end user or developer functionality; not working as the developers intended it

Comments

@ekimekim
Copy link
Contributor

In probe/docker/container.go, StartGatheringStats(), we check if c.statsConn is set and only start a new stats connection if it is not. However, we do not immediately then set this value (that happens only after some other setup inside a goroutine we then launch), meaning it might not be set by the time we get called again.
In this case, we would have two connections reporting stats for the same probe.

The simplest fix would be to add a statsStarted bool to the struct, and do:

c.Lock()
if c.statsStarted {
  c.Unlock()
  return nil
}
c.statsStarted = true
c.Unlock()

perhaps modulo some nicer handling of the Unlock

@ekimekim ekimekim added the bug Broken end user or developer functionality; not working as the developers intended it label Aug 16, 2016
@rade
Copy link
Member

rade commented Aug 16, 2016

I was wondering whether we could simply do everything up to setting c.statsConn before spawning the go-routine.

@ekimekim
Copy link
Contributor Author

That might have further impact, since it seems to be doing potentially long things like making http requests. I don't know the full context of this code.

@rade
Copy link
Member

rade commented Aug 16, 2016

That might have further impact

Hence "I was wondering whether we could" rather than "We should" :)

@ekimekim
Copy link
Contributor Author

Ah, on closer inspection, it sets up and makes a new connection, but then pushes data over it long-term. So you'd still block for the duration of connect(), which may not be acceptable.

@2opremio
Copy link
Contributor

I think we should try using the Stats() function from the client library. We discarded it in the past due to some problems I don't recall right now, but those problems (cancellation?) may be gone now.

@rade rade modified the milestone: August2016 Aug 17, 2016
@rade rade self-assigned this Aug 25, 2016
rade added a commit that referenced this issue Aug 26, 2016
...instead of rolling our own.

This also fixes #1799 - a race condition that could result in multiple
stats gatherers for a container.
rade added a commit that referenced this issue Aug 26, 2016
...instead of rolling our own.

This also fixes #1799 - a race condition that could result in multiple
stats gatherers for a container.
rade added a commit that referenced this issue Aug 26, 2016
...instead of rolling our own.

This also fixes #1799 - a race condition that could result in multiple
stats gatherers for a container.
rade added a commit that referenced this issue Aug 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken end user or developer functionality; not working as the developers intended it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants