From ee129cd4402cb100648cca9eafc6a274df1ea6b7 Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Wed, 10 Sep 2014 16:57:10 -0700 Subject: [PATCH 1/4] Proposed ContainerStatus for each individual Container in a Pod. --- pkg/api/types.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/api/types.go b/pkg/api/types.go index 63adaf38c43..ac029d877ed 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -252,7 +252,39 @@ const ( PodTerminated PodStatus = "Terminated" ) +type ContainerStateWaiting struct { +} + +type ContainerStateRunning struct { +} + +type ContainerStateTerminated struct { + ExitCode int `json:"exitCode,omitempty" yaml:"exitCode,omitempty"` + Signal int `json:"signal,omitempty" yaml:"signal,omitempty"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` +} + +type ContainerState struct { + // Only one of the following ContainerState may be specified. + // If none of them is specified, the default on is ContainerStateWaiting. + Waiting *ContainerStateWaiting `json:"waiting,omitempty" yaml:"waiting,omitempty"` + Running *ContainerStateRunning `json:"running,omitempty" yaml:"running,omitempty"` + Termination *ContainerStateTerminated `json:"termination,omitempty" yaml:"termination,omitempty"` +} + +type ContainerStatus struct { + // TODO(dchen1107): Should we rename PodStatus to a more generic name or have a separate states + // defined for container? + State ContainerState `json:"state,omitempty" yaml:"state,omitempty"` + RestartCount int `json:"restartCount,omitempty" yaml:"restartCount,omitempty"` + // TODO(dchen1107): In long run, I think we should replace this with our own struct to remove + // the dependency on docker. Also once we have done with integration with cadvisor, resource + // usage should be included. + DetailInfo docker.Container `json:"detailInfo,omitempty" yaml:"detailInfo,omitempty"` +} + // PodInfo contains one entry for every container with available info. +// TODO(dchen1107): Replace docker.Container below with ContainerStatus defined above. type PodInfo map[string]docker.Container type RestartPolicyAlways struct{} From 3faf393e7b289d7110719d0948932993953d0fdb Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Thu, 11 Sep 2014 15:22:53 -0700 Subject: [PATCH 2/4] Introduce ContainerStates. Currently keep it has the same set as PodStatus: Waiting, Running, Termination. For each state, there are some meaningful status associated with it. --- pkg/api/types.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index ac029d877ed..85bb4e9cc5c 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -253,6 +253,8 @@ const ( ) type ContainerStateWaiting struct { + // Reason could be pulling image, + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` } type ContainerStateRunning struct { @@ -276,10 +278,12 @@ type ContainerStatus struct { // TODO(dchen1107): Should we rename PodStatus to a more generic name or have a separate states // defined for container? State ContainerState `json:"state,omitempty" yaml:"state,omitempty"` - RestartCount int `json:"restartCount,omitempty" yaml:"restartCount,omitempty"` - // TODO(dchen1107): In long run, I think we should replace this with our own struct to remove - // the dependency on docker. Also once we have done with integration with cadvisor, resource + RestartCount int `json:"restartCount" yaml:"restartCount"` + // TODO(dchen1107): Introduce our own NetworkSettings struct here? + // TODO(dchen1107): Once we have done with integration with cadvisor, resource // usage should be included. + // TODO(dchen1107): In long run, I think we should replace this with our own struct to remove + // the dependency on docker. DetailInfo docker.Container `json:"detailInfo,omitempty" yaml:"detailInfo,omitempty"` } @@ -287,6 +291,8 @@ type ContainerStatus struct { // TODO(dchen1107): Replace docker.Container below with ContainerStatus defined above. type PodInfo map[string]docker.Container +//type PodInfo map[string]docker.Container + type RestartPolicyAlways struct{} // TODO(dchen1107): Define what kinds of failures should restart. From 25fbe210f65803d131314ea432d15cfd367b04bb Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Thu, 11 Sep 2014 15:30:06 -0700 Subject: [PATCH 3/4] Clean up --- pkg/api/types.go | 2 -- pkg/api/v1beta1/types.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 85bb4e9cc5c..ed20285ee37 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -291,8 +291,6 @@ type ContainerStatus struct { // TODO(dchen1107): Replace docker.Container below with ContainerStatus defined above. type PodInfo map[string]docker.Container -//type PodInfo map[string]docker.Container - type RestartPolicyAlways struct{} // TODO(dchen1107): Define what kinds of failures should restart. diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index d07128f3481..aef7283c807 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -265,6 +265,41 @@ const ( PodTerminated PodStatus = "Terminated" ) +type ContainerStateWaiting struct { + // Reason could be pulling image, + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` +} + +type ContainerStateRunning struct { +} + +type ContainerStateTerminated struct { + ExitCode int `json:"exitCode,omitempty" yaml:"exitCode,omitempty"` + Signal int `json:"signal,omitempty" yaml:"signal,omitempty"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` +} + +type ContainerState struct { + // Only one of the following ContainerState may be specified. + // If none of them is specified, the default on is ContainerStateWaiting. + Waiting *ContainerStateWaiting `json:"waiting,omitempty" yaml:"waiting,omitempty"` + Running *ContainerStateRunning `json:"running,omitempty" yaml:"running,omitempty"` + Termination *ContainerStateTerminated `json:"termination,omitempty" yaml:"termination,omitempty"` +} + +type ContainerStatus struct { + // TODO(dchen1107): Should we rename PodStatus to a more generic name or have a separate states + // defined for container? + State ContainerState `json:"state,omitempty" yaml:"state,omitempty"` + RestartCount int `json:"restartCount" yaml:"restartCount"` + // TODO(dchen1107): Introduce our own NetworkSettings struct here? + // TODO(dchen1107): Once we have done with integration with cadvisor, resource + // usage should be included. + // TODO(dchen1107): In long run, I think we should replace this with our own struct to remove + // the dependency on docker. + DetailInfo docker.Container `json:"detailInfo,omitempty" yaml:"detailInfo,omitempty"` +} + // PodInfo contains one entry for every container with available info. type PodInfo map[string]docker.Container From 7b46d8c9c5bbbbf816e654c9e40aa3697366c3bf Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Thu, 11 Sep 2014 16:07:56 -0700 Subject: [PATCH 4/4] typo --- pkg/api/types.go | 2 +- pkg/api/v1beta1/types.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index ed20285ee37..981de1b2244 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -268,7 +268,7 @@ type ContainerStateTerminated struct { type ContainerState struct { // Only one of the following ContainerState may be specified. - // If none of them is specified, the default on is ContainerStateWaiting. + // If none of them is specified, the default one is ContainerStateWaiting. Waiting *ContainerStateWaiting `json:"waiting,omitempty" yaml:"waiting,omitempty"` Running *ContainerStateRunning `json:"running,omitempty" yaml:"running,omitempty"` Termination *ContainerStateTerminated `json:"termination,omitempty" yaml:"termination,omitempty"` diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index aef7283c807..fef44d35681 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -281,7 +281,7 @@ type ContainerStateTerminated struct { type ContainerState struct { // Only one of the following ContainerState may be specified. - // If none of them is specified, the default on is ContainerStateWaiting. + // If none of them is specified, the default one is ContainerStateWaiting. Waiting *ContainerStateWaiting `json:"waiting,omitempty" yaml:"waiting,omitempty"` Running *ContainerStateRunning `json:"running,omitempty" yaml:"running,omitempty"` Termination *ContainerStateTerminated `json:"termination,omitempty" yaml:"termination,omitempty"`