-
Notifications
You must be signed in to change notification settings - Fork 2.3k
adds list command #507
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
adds list command #507
Conversation
|
Replacement for #412 |
list.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the status as an int here because we already have it as a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk... removing was there for debug because I was getting undefined (container status is broken atm) removing it.... done... removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The undefined stuff will be fixed in #499
20e5773 to
d693244
Compare
|
@crosbymichael I've completed the suggestions. Tabwriter's cool, thx! |
list.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the use of duration here less helpful than the actual time itself. While clocks will vary between systems, at least with a concrete time you know what exact time something started on that system. With a duration I now need to know when my query was executed and take that into account to get the real date/time. Let use a time instead.
6b70978 to
74302b1
Compare
|
@duglin Per our discussion since the current time value that we are storing along with container state is mics since boot of the host for the init process, and thus isn't very informative for the user... I've added a new field for the container time stamp to indicate in UTC when the container was first started on a host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we instead say System Time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the new one to creation timestamp per your suggestion..
This old one for init process start is a legacy naming issue.. in so far as it's been named and used this way for a while... I was just updating the comment to be more explanatory
74302b1 to
fb4e79b
Compare
|
@vishh Comments addressed, Thx!! |
list.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the order to be: "ID\tPID\tSTATUS\tSTARTED\tROOTFS\n", it's more consistent with linux ps output, and maybe list BUNDLE instead of ROOTFS, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hqhq Order: I have no preference on the order so... sure changed.
Thoughts on BUNDLE vs. ROOTFS:
We are making container id a required field on all of the runc commands that previously needed you to either be in the bundle or pass the old bundle as an optional parameter. Decision made at the last face to face. Thus the utility of the bundle as a thing you have to know from one command to the next on a running container is changing.
I think there is good utility for knowing the rootfs of the currently running container.
My understanding of the bundle on the other hand, is that it is an optional path argument to runc start/create or the cwd of the runc command. The bundle path is not being stored ATM (I don't believe). We take a snap shot of everything that was there at start/create and then we are done with it. Eg. we make a copy of the config.json and that copy is stored as state. The original is not used again unless they start a new container from the same bundle. From one runc start to the next, the config.json in the bundle directory could have been edited and it's not required to still be there.
So... I'd rather have either an option on list (-d etc.) to output more detail in which we add things like BUNDLE and maybe a few other items... or have a different command entirely that dumps as much or as little as you might like to see about a particular container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runc is a bit loose on the optionality of the bundle path. While runc itself lets it be optional, that's only because it then defaults to "." - but the spec itself says that its a required field. It could be argued that we should require it on the "start" cmd, if we want to promote spec compliance especially since at the f2f there was a bit of a push to have less defaults being used.
As for rootfs vs bundle in the output. Irrespective of whether runc saves that info directly or not, it does seem like showing the bundle dir might make more sense since that's the source of all info used to create the container. Also, from there you can add something like /config.json to get that info if needed. Granted from rootfs you can remove the tail of it and calculate the bundle dir, but I'm not sure I see the value in forcing people to do that. The only downside is that to get the rootfs dir they'd have to parse the config.json to find its name - but it all depends on which data we think people want to see most often. We could also just show the rootfs dir name w/o the path as a column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.. Right.. my thoughts regarding pointing them to the bundle directory so they can list the config.json are back with the concern that the config.json might not even be there any more, and certainly could have been edited by then by some higher level tool that generated it and/or is managing it. I was thinking runc list is more for what is going on after runc has loaded the config.json than telling them where the files were loaded from to launch it. At one point we were discussing a need to dump the state data including the copy of the config.json that was used to start the container.. I think it would make sense to have a command at some point that regenerates that which created the container.. this to enable cloning and introspection operations.
That said.. yeah sure as long as rootfs is allways going to be a subdirectory of the bundle path and never a full path.., I can just tail the rootfs path (using our copy of rootfs in the config.json in memory) to form the bundle path.. and then output the bundle (path) and the relative offset rootfs. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put the bundle as one of the columns. Its helpful for the user and makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good will update splitting the root fs into the bundle and rootfs as separate columns...
fb4e79b to
eb13b2a
Compare
libcontainer/container_linux.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use the start time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start time is clock ticks since boot .. it's not a timestamp.
|
Been thinking that since this might be one of the first commands we have that might be used by non-humans I think it would be good to add a |
|
@duglin yes, that is good to have |
|
How about On Tue, Jan 26, 2016 at 11:10 AM, Doug Davis [email protected]
|
|
yep - I like |
|
@mikebrow it make sure this PR doesn't keep going, we could add the |
|
Love the --format options will put a few in on the next PR :-) |
eb13b2a to
8dfe9f7
Compare
|
All comments addressed except the --format=json option which I'll do in the next PR. The list command now outputs the original bundle directory (cwd) from when the container was started and the rootfs path. We've prefix trimmed the bundle directory from the absolute rootfs path to make it take less space and look better. |
list.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you check if the PID actually exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashahab-altiscale Short answer... no.
I'm listing all containers for which there is an instance. Today that means started and has not been cleaned up (no kill or standard exit processing). Soon that should mean created or started.
This line of code (41) merely caches up the column headings for the tab writer.
With this "runc list" command I'm just loading up the containers and state using existing apis and using the existing error checking that those apis provide. The loaded containers may have just been created or started or paused, etc. If there is no init pid stored away for the container the int should be zero. If we don't like it (someone might try to perform an operation on pid zero..?) then I could substitute zero for "n/a" or "none" or some other default text. But folks might prefer to see zero as an indicator that there is no init pid yet? Let's see what it looks like when dug's create/start split drops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so a follow up question: What are we reporting in the status column? IMHO, If we are reporting 'running', we should check if the pid actually exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see what your question was about... :)
I'm just reporting the currently "stored" values for the containers and their state as stored on disk. I'm not validating whether or not the stored values accurately reflect the actual state of said containers.
To address your point/issue I could make a call to container.refreshstate() hmm... Let me sleep on that and see what the others think about it. I suppose at issue is should the runc list command be true to the stored state on disk or should I run refresh on those containers to fact check the state at the point of reporting it... then if I do refresh should I report or have the option of reporting the differences... Hmm :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.. the decision from multiple points of input is to not add any additional verification in the runc list command over and above what I already have in there. If there is an issue / disconnect in reported state we'll fix the issues when they are reported.
libcontainer/container.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this field a string and not time.Time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just putting it in a human readable form.. time.Time would work fine. FYI Time is a struct ... two int64s seconds and nanoseconds and a string for the timezone.. nill if utc.
WDYT keep it a string or let json marshal the golang unix time.Time structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use time.Time in canonical form in memory and serialized.. now waits to put it into RFC3339Nano string format until it outputs it on the list command.
8dfe9f7 to
b6f2001
Compare
|
LGTM. |
libcontainer/container_linux.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect because cwd is not right at the libcontainer level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It reported the correct directory on all my tests..
Suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For things like docker it will not. Can we maybe leave this one out and i'll think about how we want to handle this in libcontainer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.. removing it for now.
276e151 to
e930efc
Compare
|
@duglin @crosbymichael All comments addressed. Removed the bundle and rootfs columns for now. Should be ready to move forward. |
libcontainer/container.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for consistency we should remove the "Stamp" part - e.g. we don't have "InitProcessStartTimeStamp"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've stamped out the use of "stamp" :-)
|
aside from the nit, non-binding-LGTM |
e930efc to
f8adb96
Compare
|
@duglin comment re: naming of terms is addressed. |
|
thanks |
list.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this last column STARTED and everywhere else this is creationtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cause I originally called the variable container_timestamp with an output at the runc list command column name of "STARTED" so as to indicate the time when the container was started. Then vish wanted to call the variable creation_timestamp... then dug wanted to call the variable creation_time. But you're the first one to ask about the output column heading name. :-)
All that said I have no druthers, what column heading would you like to see? "CREATION TIME" does not really roll off the tongue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREATED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for those of us with simple/anal minds... for consistency: s/creation/created/ then :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CREATED" it is :-) oh and +1 i like that better.
f8adb96 to
dc028b7
Compare
|
@duglin @crosbymichael PR updated with CREATED column.. |
Signed-off-by: Mike Brown <[email protected]>
dc028b7 to
4c87126
Compare
|
@duglin Ok... all variables now indicate that is this the created time for the container. Will update the point at which the timestamp is taken when the create/start split PR is accepted. The column now says CREATED and the comments have been refreshed to indicate this is the time when the container has been created. Cheers. |
|
looks good! |
|
LGTM |
runtime: Add 'creating' to state status
Adds a runc list command. Show minimal information about the container and their current status.
Signed-off-by: Mike Brown [email protected]