Adding status command to container - #246
Conversation
There was a problem hiding this comment.
Why not handle all status? We have pausing left.
There was a problem hiding this comment.
This is what I would do and then just printf the value as a %s
diff --git a/libcontainer/container.go b/libcontainer/container.go
index a24b71b..f0ca79c 100644
--- a/libcontainer/container.go
+++ b/libcontainer/container.go
@@ -13,6 +13,21 @@ import (
// The status of a container.
type Status int
+func (s Status) String() string {
+ switch s {
+ case Running:
+ return "running"
+ case Pausing:
+ return "pausing"
+ case Paused:
+ return "paused"
+ case Checkpointed:
+ return "checkpointed"
+ case Destroyed:
+ return "destroyed"
+ }
+ return ""
+}
+
const (
// The container exists and is running.
Running Status = iota + 1|
Personally I think we have too many state related APIs in libcontainer They have overlaps and the naming is confusing. We should reconsider it when we design runC commands, and I doubt a signal status worth being a separate command. |
|
I think the last one is for statistics, not status; |
|
@hqhq |
|
@thaJeztah @rajasec You are right yes it's about statistics, just think the name is so alike as state :) |
|
@rajasec Never mind, I found we have |
There was a problem hiding this comment.
You do not need explicit breaks in Go for switch statements.
Signed-off-by: Rajasekaran <rajasec79@gmail.com> Fixed the review comments Signed-off-by: rajasec <rajasec79@gmail.com>
556d2bd to
d9c0151
Compare
|
@crosbymichael |
@crosbymichael @mrunalp
Quick way to check the container status from CLI, It provides the message to the user whether container is running checkpointed destroyed or paused ( frozen)
I've checked with Running,Checkpointed container, but frozen container, currently it will give the status as Running ( will give the right status once after #218 closure)
Usage:
runc status
Signed-off-by: Rajasekaran rajasec79@gmail.com