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

Add format to stats #24987

Merged
merged 1 commit into from
Sep 21, 2016
Merged

Add format to stats #24987

merged 1 commit into from
Sep 21, 2016

Conversation

boaz0
Copy link
Member

@boaz0 boaz0 commented Jul 24, 2016

- What I did
I attempted to use the formatter API to display docker stats.
closes #20973

- How I did it

  • Created types.ContainerStats, CStatsContext and containerStats structs
  • Moved stats_helper's Display logic to CStatsContext's Write

- How to verify it
docker stats --format "{{.PIDs}}"

@boaz0 boaz0 changed the title Stats format prod Add format to stats Jul 24, 2016
BlockRead float64
BlockWrite float64
PidsCurrent uint64
Mu sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

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

I think engine-api/types should not have mutex

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do that. I can embed ContainerStats in another struct which gives the ability to do mutex lock.
I will also move the changes I have done in engine-api into its repo.
Right now, I just want to show all the changes I made.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @AkihiroSuda

@boaz0
Copy link
Member Author

boaz0 commented Jul 25, 2016

BTW, it seems like that all the failed builds aren't related to this commit.

@thaJeztah thaJeztah added this to the 1.13.0 milestone Jul 25, 2016
@dnephin dnephin added the status/failing-ci Indicates that the PR in its current state fails the test suite label Jul 25, 2016
@dnephin
Copy link
Member

dnephin commented Jul 25, 2016

Test failures are related, validate-lint is failing because of the code changes

@boaz0
Copy link
Member Author

boaz0 commented Jul 25, 2016

@dnephin thanks for noticing. I'll fix it + rebase and push the changes soon.

@boaz0
Copy link
Member Author

boaz0 commented Jul 26, 2016

I wonder what went wrong this time 😞
It seems like it is related to a time out exception when running the search-test in docker-py.

@thaJeztah
Copy link
Member

@ripcurld00d I restarted CI just to be sure it's not a one-time issue

@boaz0
Copy link
Member Author

boaz0 commented Jul 26, 2016

@thaJeztah thanks.

@boaz0
Copy link
Member Author

boaz0 commented Jul 26, 2016

@thaJeztah now different failures.
I guess I will re-trigger tests later (when most of us are in bed).

BTW, should I create a new PR to docker/engine-api (this commit consists changes in vendor)?

@thaJeztah
Copy link
Member

@ripcurld00d you can make the PR now, or wait until we're in code review. I added the "needs-vendoring" label to let others know

@dnephin dnephin removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Jul 26, 2016
@thaJeztah thaJeztah mentioned this pull request Aug 4, 2016
2 tasks
@thaJeztah
Copy link
Member

We're ok with this; moving to code review!

BlockWrite float64
PidsCurrent uint64
Mu sync.Mutex
Err error
Copy link
Contributor

Choose a reason for hiding this comment

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

same for Err

Copy link
Member

Choose a reason for hiding this comment

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

Not sure we should move these to engine-api just to get formatting on the client.

Copy link
Member Author

@boaz0 boaz0 Aug 15, 2016

Choose a reason for hiding this comment

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

@cpuguy83 if we keep the types.ContainerStats in the container package then we will get an import cycle error:

import cycle not allowed
package github.com/docker/docker/cmd/docker
        imports github.com/docker/docker/cli/cobraadaptor
        imports github.com/docker/docker/api/client/container
        imports github.com/docker/docker/api/client/formatter
        imports github.com/docker/docker/api/client/container

Anyway, to avoid this cycle, that structure should be moved to another package. engine-api's type seems like a good place.

Copy link
Member

Choose a reason for hiding this comment

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

Move to formatter? This isn't really an API type, I don't think it belongs in engine-api.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, sounds like a better place.

@boaz0
Copy link
Member Author

boaz0 commented Aug 16, 2016

Commit was updated.
cc @tiborvass @cpuguy83 @AkihiroSuda @thaJeztah

@boaz0
Copy link
Member Author

boaz0 commented Aug 28, 2016

ummm... any feedback?

@vdemeester
Copy link
Member

It's sad that Write method of the Context object do not return an error because if we do set a wrong format, it will print the template error… It would be could to either pre-validate the format or make Write return an error to not loop for ever.

@boaz0
Copy link
Member Author

boaz0 commented Sep 6, 2016

@vdemeester, I agree! Nevertheless, it should be done in a different PR.
Anyway, I would like to work on it too, if you don't mind. 😅

BTW, should I open a proposal first?
Thanks.

@vdemeester
Copy link
Member

@ripcurld00d yes, I'm more than ok for it to be in a separate PR, and you definitely can work on it yes 😉

@boaz0
Copy link
Member Author

boaz0 commented Sep 14, 2016

@thaJeztah rebased:

  • I think the "needs-vendoring" tag can be removed.
  • It seems like tests failed due to a Jenkins slave connectivity problem.

@thaJeztah
Copy link
Member

@ripcurld00d triggered a rebuild for CI

@vdemeester does the current implementation LGTY (if the other issue is handled in a different PR)?

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
@boaz0
Copy link
Member Author

boaz0 commented Sep 18, 2016

Rebased (2) successfully 😰 :godmode:
@vdemeester @thaJeztah

@boaz0
Copy link
Member Author

boaz0 commented Sep 21, 2016

ping 😊

@vdemeester
Copy link
Member

vdemeester commented Sep 21, 2016

LGTM 🐸
/cc @dnephin @cpuguy83 @runcom

@dnephin
Copy link
Member

dnephin commented Sep 21, 2016

LGTM

@dnephin dnephin merged commit c0699cd into moby:master Sep 21, 2016
@thaJeztah
Copy link
Member

Looks like this went in without documentation changes opened #26779 for tracking that. @ripcurld00d can you do a follow up to update the documentation?

@thaJeztah
Copy link
Member

and ping @albers @sdurrheimer for the completion scripts ❤️

@runcom
Copy link
Member

runcom commented Sep 21, 2016

looks like my comment went un-noticed as well :)


// ContainerStats represents the containers statistics data.
type ContainerStats struct {
Mu sync.RWMutex
Copy link
Member

Choose a reason for hiding this comment

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

Mu? :) how about Mutex?

BTW, exposing the mutex seems weird to me, I expected what needs to be done outside of this package was abstracted here so that the mutex is just an internal property of this struct. Exposing it, uhm, doesn't sound good. Maybe locking up in the call stack instead? /cc @cpuguy83 wdyt

Copy link
Member

Choose a reason for hiding this comment

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

agreed

Copy link
Member

Choose a reason for hiding this comment

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

@ripcurld00d @vdemeester I'd love to have this taken care of :(

Copy link
Member Author

@boaz0 boaz0 Sep 21, 2016

Choose a reason for hiding this comment

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

@runcom I was about to suggest myself but I don't mind you fixing this.

Copy link
Member

Choose a reason for hiding this comment

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

@runcom I was about to suggest myself but I don't mind you fixing this.

yeah, I'll try to find some time so feel free to go ahead and take a stab at this...

Copy link
Member

Choose a reason for hiding this comment

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

@ripcurld00d you can go ahead, @runcom suggested we should take care of it, not that he would like to take care of it. It's all yours @ripcurld00d 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

@runcom @vdemeester -- thanks. I would love to finish what I have started :)

@albers
Copy link
Member

albers commented Sep 21, 2016

I'm a bit disappointed that --format does not give access to container names.

It has always been bothering me that the first column of docker stats shows container IDs. This is not very helpful because the rows keep flipping around. To get the names, you have to issue docker ps <container names>. This means that I have to decide whether I want to automatically see all containers as IDs or if I have to manually select them just because I want to see descriptive names.

How about adding .ID and .Name placeholders that let me decide what to see instead of the automatic .Container column?

@boaz0
Copy link
Member Author

boaz0 commented Sep 21, 2016

@albers, this patch supposes to add format to the stats command. The next part, which I would like to work on, is adding container names to the stats.

@albers
Copy link
Member

albers commented Sep 21, 2016

@ripcurld00d That's great news! Thanks.

@thaJeztah
Copy link
Member

@ripcurld00d oh, that means #20973 should probably not be closed if this doesn't support .Names?

@boaz0
Copy link
Member Author

boaz0 commented Sep 21, 2016

@thaJeztah that's right.

@thaJeztah
Copy link
Member

docs were addressed in #26892

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

Successfully merging this pull request may close these issues.

Proposal: Docker stats to show names instead of IDs
10 participants