Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

add docker stats (new in docker1.5)#71

Merged
donhcd merged 29 commits into
samalba:masterfrom
donhcd:stats
Feb 4, 2016
Merged

add docker stats (new in docker1.5)#71
donhcd merged 29 commits into
samalba:masterfrom
donhcd:stats

Conversation

@donhcd

@donhcd donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator

I'm very open to suggestions on a better interface for stats, or better ways to write this

@donhcd

donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator Author

ping @vieux @aluzzardi please take a look when you get a moment

Comment thread dockerclient.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove these debug prints first...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point 👍
On Mon, Feb 2, 2015 at 17:59 Brian Bland notifications@github.com wrote:

In dockerclient.go
#71 (comment):

  •   for {
    
  •       go func() {
    
  •           defer func() {
    
  •               recover() // ugly but necessary for sending on closed chan
    
  •           }()
    
  •           var containerStats stats.Stats
    
  •           if err := decoder.Decode(&containerStats); err != nil {
    
  •               internalErrorChan <- err
    
  •               return
    
  •           }
    
  •           internalStatsChan <- containerStats
    
  •       }()
    
  •       select {
    
  •       case containerStats := <-internalStatsChan:
    
  •           fmt.Printf("first\n")
    

You should remove these debug prints first...


Reply to this email directly or view it on GitHub
https://github.com/samalba/dockerclient/pull/71/files#r23977267.

@donhcd donhcd force-pushed the stats branch 2 times, most recently from 388f1a6 to af77c7c Compare February 3, 2015 02:04
Comment thread dockerclient.go Outdated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No way, we should never import docker packages directly.

The main purpose of starting this library was to be entirely client side (everything over HTTP, no docker internal import). This can break the library anytime.

@samalba

samalba commented Feb 3, 2015

Copy link
Copy Markdown
Owner

Does the docker remote API have support for stats yet? If yes, then we should leverage it. If not, the library cannot support it and this PR should be rejected.

@donhcd

donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator Author

@samalba I am using the docker remote API. I'm only importing docker/api/stats for the stats.Stats type, which is the type that the remote API encodes. This type should be relatively stable, considering https://github.com/docker/docker/blob/master/daemon/stats.go#L36, but I can redeclare this struct if you prefer that

@samalba

samalba commented Feb 3, 2015

Copy link
Copy Markdown
Owner

@donhcd Got it. So you should redeclare the types you need over there: https://github.com/samalba/dockerclient/blob/master/types.go

@donhcd

donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator Author

okay, will do

@donhcd

donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator Author

redeclared the types, but there's actually a race in the test right now, which I'm working on resolving

@donhcd

donhcd commented Feb 3, 2015

Copy link
Copy Markdown
Collaborator Author

fixed the race, ready for review now. I'm running the tests 1000 times just in case any other races pop up, but I haven't seen any problems yet. ping @samalba

@aluzzardi

Copy link
Copy Markdown
Collaborator

mockclient/mock.go should be updated as well.

@donhcd

donhcd commented Feb 4, 2015

Copy link
Copy Markdown
Collaborator Author

@aluzzardi updated. I'm a little confused what mockclient is used for... is it used somewhere?

@aluzzardi

Copy link
Copy Markdown
Collaborator

@donhcd It's for library clients to use in order to mock dockerclient (as in, to fake dockerclient responses in unit tests).

Here's an example on how we use this on Swarm:
https://github.com/docker/swarm/blob/master/cluster/node_test.go#L43

@donhcd

donhcd commented Feb 4, 2015

Copy link
Copy Markdown
Collaborator Author

ah, I see. thanks for the link :)

@donhcd

donhcd commented Feb 9, 2015

Copy link
Copy Markdown
Collaborator Author

ping @aluzzardi @vieux

@vieux

vieux commented Feb 9, 2015

Copy link
Copy Markdown
Contributor

@samalba are you ok with the current format ?

@samalba

samalba commented Feb 9, 2015

Copy link
Copy Markdown
Owner

@vieux Looks ok to me, what do you think?

@vieux

vieux commented Feb 9, 2015

Copy link
Copy Markdown
Contributor

same, please @crosbymichael can you take a look, you are the most familiar with the stats endpoint.

@donhcd

donhcd commented Mar 31, 2015

Copy link
Copy Markdown
Collaborator Author

ping @crosbymichael

Conflicts:
	dockerclient.go
	dockerclient_test.go
	example_responses.go
	interface.go
	mockclient/mock.go
	types.go
@donhcd donhcd force-pushed the stats branch 3 times, most recently from 8e9eccd to 04885d9 Compare February 3, 2016 06:29
Comment thread dockerclient.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately stats don't get added until API 1.17, so you'll have to bump APIVersion. I don't know what the delta between 1.15 and 1.17 is though and if we'd be missing anything here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the general approach of this repo so far has just been to keep the API version the same despite adding API calls that rely on newer API versions (e.g. ListNetworks). Given that (1) we don't have a testing framework to actually test all of the dockerclient methods on docker engines of all versions and (2) it's not uncommon for API changes to be breaking and undocumented, switching the APIVersion has high risk and low reward :/

If we were to switch the APIVersion, it should probably be in a separate PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Def. agree we should do it in a separate PR. For that change we should just tag the repo at 1.5 and move on. If someone wants the older version, they can pull the tag. How about a compromise for this PR until we get the library in better shape by just commenting it (and maybe ListNetworks too) so we don't forget.

The flip side of this is it looks really weird in the UCP (and presumably DTR) logs that says the API version is 1.15.

@pdevine

pdevine commented Feb 3, 2016

Copy link
Copy Markdown

The only thing that really concerns me is we should bump the APIVersion up, but I don't know what's missing in here vs. 1.17. Otherwise, LGTM.

@donhcd

donhcd commented Feb 4, 2016

Copy link
Copy Markdown
Collaborator Author

@pdevine I just added a comment to the APIVersion

@pdevine

pdevine commented Feb 4, 2016

Copy link
Copy Markdown

LGTM.

donhcd added a commit that referenced this pull request Feb 4, 2016
add docker stats (new in docker1.5)
@donhcd donhcd merged commit 4278ba3 into samalba:master Feb 4, 2016
@donhcd donhcd deleted the stats branch February 4, 2016 23:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants