From 178b4275cac0fd34502eb83503ecbefe31fcd914 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 18 May 2017 17:44:34 -0700 Subject: [PATCH] api/types/container: nice enum values for status Signed-off-by: Stephen J Day --- api/types/container/container.pb.go | 94 +++++++++++++++-------------- api/types/container/container.proto | 13 ++-- linux/container.go | 8 +-- linux/shim/service.go | 14 ++--- services/execution/service.go | 8 +-- 5 files changed, 72 insertions(+), 65 deletions(-) diff --git a/api/types/container/container.pb.go b/api/types/container/container.pb.go index 573265286..e9abe0b97 100644 --- a/api/types/container/container.pb.go +++ b/api/types/container/container.pb.go @@ -47,11 +47,11 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package type Status int32 const ( - Status_UNKNOWN Status = 0 - Status_CREATED Status = 1 - Status_RUNNING Status = 2 - Status_STOPPED Status = 3 - Status_PAUSED Status = 4 + StatusUnknown Status = 0 + StatusCreated Status = 1 + StatusRunning Status = 2 + StatusStopped Status = 3 + StatusPaused Status = 4 ) var Status_name = map[int32]string{ @@ -1413,44 +1413,48 @@ func init() { } var fileDescriptorContainer = []byte{ - // 612 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0xcd, 0xd8, 0xce, 0x8f, 0x6f, 0xbe, 0xe6, 0xb3, 0x86, 0x0a, 0xb9, 0x41, 0x4a, 0xa2, 0x08, - 0x89, 0x08, 0x09, 0x47, 0xa4, 0x0b, 0xd8, 0xba, 0xb5, 0x55, 0x2a, 0x44, 0x12, 0x26, 0x8e, 0xe8, - 0x2e, 0x9a, 0xc6, 0xc6, 0x0c, 0x6a, 0xec, 0xc8, 0x1e, 0x17, 0xb2, 0xe3, 0x11, 0x78, 0x06, 0xf6, - 0xbc, 0x47, 0x97, 0x2c, 0x59, 0x15, 0x9a, 0x27, 0x41, 0x33, 0x4e, 0xea, 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5d, 0x54, 0x81, 0x3f, 0xa3, 0x5c, 0xc6, - 0x54, 0x1f, 0x34, 0xef, 0x5c, 0xc6, 0xdb, 0xfe, 0xb4, 0x07, 0xb5, 0x8b, 0xcb, 0x76, 0xe9, 0xeb, - 0xaf, 0x36, 0x22, 0xb5, 0x7c, 0xcc, 0xe6, 0xdd, 0xb7, 0xa0, 0x5f, 0x2f, 0x82, 0x6b, 0xa0, 0xb9, - 0x27, 0xc7, 0x9e, 0x51, 0xc2, 0x55, 0x50, 0x47, 0xa3, 0x37, 0x06, 0xc2, 0x00, 0x95, 0x43, 0xe2, - 0xda, 0x9e, 0x6b, 0x28, 0x58, 0x87, 0xf2, 0xc4, 0xb3, 0x89, 0x67, 0xa8, 0xb8, 0x01, 0xe0, 0x9e, - 0xb8, 0x87, 0x33, 0xdb, 0x71, 0x5c, 0xc7, 0xd0, 0x04, 0x6d, 0x6c, 0x4f, 0x27, 0xae, 0x63, 0x94, - 0x9f, 0xbe, 0x82, 0xca, 0x66, 0xbf, 0x3a, 0x54, 0xa7, 0xc3, 0xd7, 0xc3, 0xd1, 0xbb, 0xa1, 0x51, - 0x12, 0x45, 0xae, 0xe4, 0x18, 0x48, 0x14, 0x64, 0x3a, 0x1c, 0x1e, 0x0f, 0x8f, 0x0c, 0x45, 0x14, - 0x13, 0x6f, 0x34, 0x1e, 0xbb, 0x8e, 0xa1, 0xde, 0x50, 0xd2, 0x0e, 0xcc, 0x8b, 0xab, 0x56, 0xe9, - 0xe7, 0x55, 0xab, 0xf4, 0x65, 0xdd, 0x42, 0x17, 0xeb, 0x16, 0xfa, 0xb1, 0x6e, 0xa1, 0xdf, 0xeb, - 0x16, 0x3a, 0xad, 0x48, 0x7b, 0xfb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x9b, 0x55, 0x0d, - 0x2f, 0x04, 0x00, 0x00, + // 680 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0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, 0xfe, 0x8b, 0x9e, 0x96, 0xab, 0xfd, 0x7b, 0x7a, 0x66, + 0x6e, 0xa6, 0xc4, 0x98, 0xbe, 0xa1, 0xc1, 0x09, 0xe5, 0x7c, 0xda, 0xdd, 0xd6, 0xa4, 0x75, 0xbe, + 0x1b, 0x61, 0xc4, 0xb0, 0xc7, 0x79, 0x77, 0xdc, 0xeb, 0xed, 0xf7, 0xf6, 0x34, 0x79, 0x9d, 0x77, + 0x13, 0x4a, 0x09, 0xf5, 0x39, 0x3f, 0x1c, 0xf5, 0x07, 0x03, 0xc7, 0xd6, 0x94, 0x75, 0x7e, 0xc8, + 0x82, 0x30, 0xc4, 0x1e, 0xbc, 0x7b, 0x35, 0x96, 0x5a, 0xd3, 0x4e, 0xcf, 0xcc, 0x8d, 0x94, 0x1e, + 0xa0, 0x24, 0xc6, 0x5e, 0xad, 0xfa, 0xfe, 0x93, 0x91, 0xfb, 0xf6, 0xd9, 0x58, 0x4e, 0xbb, 0xab, + 0x9f, 0x5f, 0x1a, 0xb9, 0x1f, 0x97, 0x46, 0xee, 0xdd, 0xc2, 0x90, 0xce, 0x17, 0x86, 0xf4, 0x7d, + 0x61, 0x48, 0xbf, 0x16, 0x86, 0x74, 0x58, 0x10, 0xdb, 0xdc, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, + 0x0d, 0x06, 0xaf, 0x6b, 0x9e, 0x04, 0x00, 0x00, } diff --git a/api/types/container/container.proto b/api/types/container/container.proto index 3ae378615..e1f63eb3b 100644 --- a/api/types/container/container.proto +++ b/api/types/container/container.proto @@ -7,11 +7,14 @@ import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; enum Status { - UNKNOWN = 0; - CREATED = 1; - RUNNING = 2; - STOPPED = 3; - PAUSED = 4; + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.enum_customname) = "Status"; + + UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "StatusUnknown"]; + CREATED = 1 [(gogoproto.enumvalue_customname) = "StatusCreated"]; + RUNNING = 2 [(gogoproto.enumvalue_customname) = "StatusRunning"]; + STOPPED = 3 [(gogoproto.enumvalue_customname) = "StatusStopped"]; + PAUSED = 4 [(gogoproto.enumvalue_customname) = "StatusPaused"]; } message Container { diff --git a/linux/container.go b/linux/container.go index e09a9e045..3939bee7b 100644 --- a/linux/container.go +++ b/linux/container.go @@ -57,13 +57,13 @@ func (c *Container) State(ctx context.Context) (plugin.State, error) { } var status plugin.Status switch response.Status { - case container.Status_CREATED: + case container.StatusCreated: status = plugin.CreatedStatus - case container.Status_RUNNING: + case container.StatusRunning: status = plugin.RunningStatus - case container.Status_STOPPED: + case container.StatusStopped: status = plugin.StoppedStatus - case container.Status_PAUSED: + case container.StatusPaused: status = plugin.PausedStatus // TODO: containerd.DeletedStatus } diff --git a/linux/shim/service.go b/linux/shim/service.go index a8a857f33..53e0dd334 100644 --- a/linux/shim/service.go +++ b/linux/shim/service.go @@ -160,16 +160,16 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi. if err != nil { return nil, err } - status := container.Status_UNKNOWN + status := container.StatusUnknown switch st { case "created": - status = container.Status_CREATED + status = container.StatusCreated case "running": - status = container.Status_RUNNING + status = container.StatusRunning case "stopped": - status = container.Status_STOPPED + status = container.StatusStopped case "paused": - status = container.Status_PAUSED + status = container.StatusPaused } o := &shimapi.StateResponse{ ID: s.id, @@ -181,12 +181,12 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi. s.mu.Lock() defer s.mu.Unlock() for _, p := range s.processes { - status := container.Status_RUNNING + status := container.StatusRunning if err := unix.Kill(p.Pid(), 0); err != nil { if err != syscall.ESRCH { return nil, err } - status = container.Status_STOPPED + status = container.StatusStopped } o.Processes = append(o.Processes, &container.Process{ Pid: uint32(p.Pid()), diff --git a/services/execution/service.go b/services/execution/service.go index 149793021..d94f64f72 100644 --- a/services/execution/service.go +++ b/services/execution/service.go @@ -150,13 +150,13 @@ func containerFromContainerd(ctx context.Context, c plugin.Container) (*containe var status container.Status switch state.Status() { case plugin.CreatedStatus: - status = container.Status_CREATED + status = container.StatusCreated case plugin.RunningStatus: - status = container.Status_RUNNING + status = container.StatusRunning case plugin.StoppedStatus: - status = container.Status_STOPPED + status = container.StatusStopped case plugin.PausedStatus: - status = container.Status_PAUSED + status = container.StatusPaused default: log.G(ctx).WithField("status", state.Status()).Warn("unknown status") }