Commit ecfde2b8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #35998 from yujuhong/fix_enum

Automatic merge from submit-queue CRI: Rename container/sandbox states The enum constants are not namespaced. The shorter, unspecifc names are likely to cause naming conflicts in the future. Also replace "SandBox" with "Sandbox" in the API for consistency. /cc @kubernetes/sig-node
parents 3d33b45e 8a6285d8
......@@ -119,7 +119,7 @@ func (r *FakeRuntimeService) RunPodSandbox(config *runtimeApi.PodSandboxConfig)
// fixed name from BuildSandboxName() for easily making fake sandboxes.
podSandboxID := BuildSandboxName(config.Metadata)
createdAt := time.Now().Unix()
readyState := runtimeApi.PodSandBoxState_READY
readyState := runtimeApi.PodSandboxState_SANDBOX_READY
r.Sandboxes[podSandboxID] = &FakePodSandbox{
PodSandboxStatus: runtimeApi.PodSandboxStatus{
Id: &podSandboxID,
......@@ -143,7 +143,7 @@ func (r *FakeRuntimeService) StopPodSandbox(podSandboxID string) error {
r.Called = append(r.Called, "StopPodSandbox")
notReadyState := runtimeApi.PodSandBoxState_NOTREADY
notReadyState := runtimeApi.PodSandboxState_SANDBOX_NOTREADY
if s, ok := r.Sandboxes[podSandboxID]; ok {
s.State = &notReadyState
} else {
......@@ -231,7 +231,7 @@ func (r *FakeRuntimeService) CreateContainer(podSandboxID string, config *runtim
// fixed BuildContainerName() for easily making fake containers.
containerID := BuildContainerName(config.Metadata, podSandboxID)
createdAt := time.Now().Unix()
createdState := runtimeApi.ContainerState_CREATED
createdState := runtimeApi.ContainerState_CONTAINER_CREATED
imageRef := config.Image.GetImage()
r.Containers[containerID] = &FakeContainer{
ContainerStatus: runtimeApi.ContainerStatus{
......@@ -263,7 +263,7 @@ func (r *FakeRuntimeService) StartContainer(containerID string) error {
// Set container to running.
startedAt := time.Now().Unix()
runningState := runtimeApi.ContainerState_RUNNING
runningState := runtimeApi.ContainerState_CONTAINER_RUNNING
c.State = &runningState
c.StartedAt = &startedAt
......@@ -283,7 +283,7 @@ func (r *FakeRuntimeService) StopContainer(containerID string, timeout int64) er
// Set container to exited state.
finishedAt := time.Now().Unix()
exitedState := runtimeApi.ContainerState_EXITED
exitedState := runtimeApi.ContainerState_CONTAINER_EXITED
c.State = &exitedState
c.FinishedAt = &finishedAt
......
......@@ -20,7 +20,7 @@ service RuntimeService {
rpc RemovePodSandbox(RemovePodSandboxRequest) returns (RemovePodSandboxResponse) {}
// PodSandboxStatus returns the status of the PodSandbox.
rpc PodSandboxStatus(PodSandboxStatusRequest) returns (PodSandboxStatusResponse) {}
// ListPodSandbox returns a list of SandBox.
// ListPodSandbox returns a list of Sandbox.
rpc ListPodSandbox(ListPodSandboxRequest) returns (ListPodSandboxResponse) {}
// CreateContainer creates a new container in specified PodSandbox
......@@ -270,15 +270,15 @@ message Namespace {
optional NamespaceOption options = 2;
}
// LinuxSandBoxStatus contains status specific to Linux sandboxes.
// LinuxSandboxStatus contains status specific to Linux sandboxes.
message LinuxPodSandboxStatus {
// Namespaces contains paths to the sandbox's namespaces.
optional Namespace namespaces = 1;
}
enum PodSandBoxState {
READY = 0;
NOTREADY = 1;
enum PodSandboxState {
SANDBOX_READY = 0;
SANDBOX_NOTREADY = 1;
}
// PodSandboxStatus contains the status of the PodSandbox.
......@@ -288,7 +288,7 @@ message PodSandboxStatus {
// Metadata of the sandbox.
optional PodSandboxMetadata metadata = 2;
// State of the sandbox.
optional PodSandBoxState state = 3;
optional PodSandboxState state = 3;
// Creation timestamp of the sandbox in nanoseconds.
optional int64 created_at = 4;
// Network contains network status if network is handled by the runtime.
......@@ -313,7 +313,7 @@ message PodSandboxFilter {
// ID of the sandbox.
optional string id = 1;
// State of the sandbox.
optional PodSandBoxState state = 2;
optional PodSandboxState state = 2;
// LabelSelector to select matches.
// Only api.MatchLabels is supported for now and the requirements
// are ANDed. MatchExpressions is not supported yet.
......@@ -333,7 +333,7 @@ message PodSandbox {
// Metadata of the sandbox
optional PodSandboxMetadata metadata = 2;
// The state of the PodSandbox
optional PodSandBoxState state = 3;
optional PodSandboxState state = 3;
// Creation timestamps of the sandbox in nanoseconds
optional int64 created_at = 4;
// The labels of the PodSandbox
......@@ -529,10 +529,10 @@ message RemoveContainerRequest {
message RemoveContainerResponse {}
enum ContainerState {
CREATED = 0;
RUNNING = 1;
EXITED = 2;
UNKNOWN = 3;
CONTAINER_CREATED = 0;
CONTAINER_RUNNING = 1;
CONTAINER_EXITED = 2;
CONTAINER_UNKNOWN = 3;
}
// ContainerFilter is used to filter containers.
......
......@@ -206,11 +206,11 @@ func ConvertPodStatusToRunningPod(runtimeName string, podStatus *PodStatus) Pod
// This is only needed because we need to return sandboxes as if they were
// kubecontainer.Containers to avoid substantial changes to PLEG.
// TODO: Remove this once it becomes obsolete.
func SandboxToContainerState(state runtimeApi.PodSandBoxState) ContainerState {
func SandboxToContainerState(state runtimeApi.PodSandboxState) ContainerState {
switch state {
case runtimeApi.PodSandBoxState_READY:
case runtimeApi.PodSandboxState_SANDBOX_READY:
return ContainerStateRunning
case runtimeApi.PodSandBoxState_NOTREADY:
case runtimeApi.PodSandboxState_SANDBOX_NOTREADY:
return ContainerStateExited
}
return ContainerStateUnknown
......
......@@ -100,13 +100,13 @@ func toRuntimeAPIContainer(c *dockertypes.Container) (*runtimeApi.Container, err
func toDockerContainerStatus(state runtimeApi.ContainerState) string {
switch state {
case runtimeApi.ContainerState_CREATED:
case runtimeApi.ContainerState_CONTAINER_CREATED:
return "created"
case runtimeApi.ContainerState_RUNNING:
case runtimeApi.ContainerState_CONTAINER_RUNNING:
return "running"
case runtimeApi.ContainerState_EXITED:
case runtimeApi.ContainerState_CONTAINER_EXITED:
return "exited"
case runtimeApi.ContainerState_UNKNOWN:
case runtimeApi.ContainerState_CONTAINER_UNKNOWN:
fallthrough
default:
return "unknown"
......@@ -118,24 +118,24 @@ func toRuntimeAPIContainerState(state string) runtimeApi.ContainerState {
// we upgrade docker.
switch {
case strings.HasPrefix(state, statusRunningPrefix):
return runtimeApi.ContainerState_RUNNING
return runtimeApi.ContainerState_CONTAINER_RUNNING
case strings.HasPrefix(state, statusExitedPrefix):
return runtimeApi.ContainerState_EXITED
return runtimeApi.ContainerState_CONTAINER_EXITED
case strings.HasPrefix(state, statusCreatedPrefix):
return runtimeApi.ContainerState_CREATED
return runtimeApi.ContainerState_CONTAINER_CREATED
default:
return runtimeApi.ContainerState_UNKNOWN
return runtimeApi.ContainerState_CONTAINER_UNKNOWN
}
}
func toRuntimeAPISandboxState(state string) runtimeApi.PodSandBoxState {
func toRuntimeAPISandboxState(state string) runtimeApi.PodSandboxState {
// Parse the state string in dockertypes.Container. This could break when
// we upgrade docker.
switch {
case strings.HasPrefix(state, statusRunningPrefix):
return runtimeApi.PodSandBoxState_READY
return runtimeApi.PodSandboxState_SANDBOX_READY
default:
return runtimeApi.PodSandBoxState_NOTREADY
return runtimeApi.PodSandboxState_SANDBOX_NOTREADY
}
}
......
......@@ -30,10 +30,10 @@ func TestConvertDockerStatusToRuntimeAPIState(t *testing.T) {
input string
expected runtimeApi.ContainerState
}{
{input: "Up 5 hours", expected: runtimeApi.ContainerState_RUNNING},
{input: "Exited (0) 2 hours ago", expected: runtimeApi.ContainerState_EXITED},
{input: "Created", expected: runtimeApi.ContainerState_CREATED},
{input: "Random string", expected: runtimeApi.ContainerState_UNKNOWN},
{input: "Up 5 hours", expected: runtimeApi.ContainerState_CONTAINER_RUNNING},
{input: "Exited (0) 2 hours ago", expected: runtimeApi.ContainerState_CONTAINER_EXITED},
{input: "Created", expected: runtimeApi.ContainerState_CONTAINER_CREATED},
{input: "Random string", expected: runtimeApi.ContainerState_CONTAINER_UNKNOWN},
}
for _, test := range testCases {
......
......@@ -327,7 +327,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
var reason, message string
if r.State.Running {
// Container is running.
state = runtimeApi.ContainerState_RUNNING
state = runtimeApi.ContainerState_CONTAINER_RUNNING
} else {
// Container is *not* running. We need to get more details.
// * Case 1: container has run and exited with non-zero finishedAt
......@@ -336,7 +336,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
// time, but a non-zero exit code.
// * Case 3: container has been created, but not started (yet).
if !finishedAt.IsZero() { // Case 1
state = runtimeApi.ContainerState_EXITED
state = runtimeApi.ContainerState_CONTAINER_EXITED
switch {
case r.State.OOMKilled:
// TODO: consider exposing OOMKilled via the runtimeAPI.
......@@ -349,13 +349,13 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
reason = "Error"
}
} else if r.State.ExitCode != 0 { // Case 2
state = runtimeApi.ContainerState_EXITED
state = runtimeApi.ContainerState_CONTAINER_EXITED
// Adjust finshedAt and startedAt time to createdAt time to avoid
// the confusion.
finishedAt, startedAt = createdAt, createdAt
reason = "ContainerCannotRun"
} else { // Case 3
state = runtimeApi.ContainerState_CREATED
state = runtimeApi.ContainerState_CONTAINER_CREATED
}
message = r.State.Error
}
......
......@@ -62,7 +62,7 @@ func TestListContainers(t *testing.T) {
}
expected := []*runtimeApi.Container{}
state := runtimeApi.ContainerState_RUNNING
state := runtimeApi.ContainerState_CONTAINER_RUNNING
var createdAt int64 = 0
for i := range configs {
// We don't care about the sandbox id; pass a bogus one.
......@@ -105,7 +105,7 @@ func TestContainerStatus(t *testing.T) {
var defaultTime time.Time
dt := defaultTime.UnixNano()
ct, st, ft := dt, dt, dt
state := runtimeApi.ContainerState_CREATED
state := runtimeApi.ContainerState_CONTAINER_CREATED
// The following variables are not set in FakeDockerClient.
imageRef := DockerImageIDPrefix + ""
exitCode := int32(0)
......@@ -149,7 +149,7 @@ func TestContainerStatus(t *testing.T) {
// Advance the clock and start the container.
fClock.SetTime(time.Now())
*expected.StartedAt = fClock.Now().UnixNano()
*expected.State = runtimeApi.ContainerState_RUNNING
*expected.State = runtimeApi.ContainerState_CONTAINER_RUNNING
err = ds.StartContainer(id)
assert.NoError(t, err)
......@@ -159,7 +159,7 @@ func TestContainerStatus(t *testing.T) {
// Advance the clock and stop the container.
fClock.SetTime(time.Now().Add(1 * time.Hour))
*expected.FinishedAt = fClock.Now().UnixNano()
*expected.State = runtimeApi.ContainerState_EXITED
*expected.State = runtimeApi.ContainerState_CONTAINER_EXITED
*expected.Reason = "Completed"
err = ds.StopContainer(id, 0)
......
......@@ -192,9 +192,9 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeApi.PodS
ct := createdAt.UnixNano()
// Translate container to sandbox state.
state := runtimeApi.PodSandBoxState_NOTREADY
state := runtimeApi.PodSandboxState_SANDBOX_NOTREADY
if r.State.Running {
state = runtimeApi.PodSandBoxState_READY
state = runtimeApi.PodSandboxState_SANDBOX_READY
}
IP, err := ds.getIP(r)
if err != nil {
......@@ -244,11 +244,11 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]
f.Add("id", filter.GetId())
}
if filter.State != nil {
if filter.GetState() == runtimeApi.PodSandBoxState_READY {
if filter.GetState() == runtimeApi.PodSandboxState_SANDBOX_READY {
// Only list running containers.
opts.All = false
} else {
// runtimeApi.PodSandBoxState_NOTREADY can mean the
// runtimeApi.PodSandboxState_SANDBOX_NOTREADY can mean the
// container is in any of the non-running state (e.g., created,
// exited). We can't tell docker to filter out running
// containers directly, so we'll need to filter them out
......@@ -277,7 +277,7 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]
glog.V(5).Infof("Unable to convert docker to runtime API sandbox: %v", err)
continue
}
if filterOutReadySandboxes && converted.GetState() == runtimeApi.PodSandBoxState_READY {
if filterOutReadySandboxes && converted.GetState() == runtimeApi.PodSandboxState_SANDBOX_READY {
continue
}
......
......@@ -63,7 +63,7 @@ func TestListSandboxes(t *testing.T) {
}
expected := []*runtimeApi.PodSandbox{}
state := runtimeApi.PodSandBoxState_READY
state := runtimeApi.PodSandboxState_SANDBOX_READY
var createdAt int64 = 0
for i := range configs {
id, err := ds.RunPodSandbox(configs[i])
......@@ -98,7 +98,7 @@ func TestSandboxStatus(t *testing.T) {
fakeIP := "2.3.4.5"
fakeNS := fmt.Sprintf("/proc/%d/ns/net", os.Getpid())
state := runtimeApi.PodSandBoxState_READY
state := runtimeApi.PodSandboxState_SANDBOX_READY
ct := int64(0)
hostNetwork := false
expected := &runtimeApi.PodSandboxStatus{
......@@ -128,7 +128,7 @@ func TestSandboxStatus(t *testing.T) {
assert.Equal(t, expected, status)
// Stop the sandbox.
*expected.State = runtimeApi.PodSandBoxState_NOTREADY
*expected.State = runtimeApi.PodSandboxState_SANDBOX_NOTREADY
err = ds.StopPodSandbox(id)
assert.NoError(t, err)
status, err = ds.PodSandboxStatus(id)
......
......@@ -72,13 +72,13 @@ func (c containerStatusByCreated) Less(i, j int) bool { return c[i].CreatedAt.Af
// toKubeContainerState converts runtimeApi.ContainerState to kubecontainer.ContainerState.
func toKubeContainerState(state runtimeApi.ContainerState) kubecontainer.ContainerState {
switch state {
case runtimeApi.ContainerState_CREATED:
case runtimeApi.ContainerState_CONTAINER_CREATED:
return kubecontainer.ContainerStateCreated
case runtimeApi.ContainerState_RUNNING:
case runtimeApi.ContainerState_CONTAINER_RUNNING:
return kubecontainer.ContainerStateRunning
case runtimeApi.ContainerState_EXITED:
case runtimeApi.ContainerState_CONTAINER_EXITED:
return kubecontainer.ContainerStateExited
case runtimeApi.ContainerState_UNKNOWN:
case runtimeApi.ContainerState_CONTAINER_UNKNOWN:
return kubecontainer.ContainerStateUnknown
}
......
......@@ -301,7 +301,7 @@ func (m *kubeGenericRuntimeManager) getKubeletContainers(allContainers bool) ([]
LabelSelector: map[string]string{kubernetesManagedLabel: "true"},
}
if !allContainers {
runningState := runtimeApi.ContainerState_RUNNING
runningState := runtimeApi.ContainerState_CONTAINER_RUNNING
filter.State = &runningState
}
......@@ -390,7 +390,7 @@ func (m *kubeGenericRuntimeManager) getPodContainerStatuses(uid kubetypes.UID, n
CreatedAt: time.Unix(0, status.GetCreatedAt()),
}
if c.GetState() == runtimeApi.ContainerState_RUNNING {
if c.GetState() == runtimeApi.ContainerState_CONTAINER_RUNNING {
cStatus.StartedAt = time.Unix(0, status.GetStartedAt())
} else {
cStatus.Reason = status.GetReason()
......
......@@ -154,7 +154,7 @@ func (cgc *containerGC) evictableContainers(minAge time.Duration) (containersByE
newestGCTime := time.Now().Add(-minAge)
for _, container := range containers {
// Prune out running containers.
if container.GetState() == runtimeApi.ContainerState_RUNNING {
if container.GetState() == runtimeApi.ContainerState_CONTAINER_RUNNING {
continue
}
......@@ -249,7 +249,7 @@ func (cgc *containerGC) evictSandboxes(minAge time.Duration) error {
newestGCTime := time.Now().Add(-minAge)
for _, sandbox := range sandboxes {
// Prune out ready sandboxes.
if sandbox.GetState() == runtimeApi.PodSandBoxState_READY {
if sandbox.GetState() == runtimeApi.PodSandboxState_SANDBOX_READY {
continue
}
......
......@@ -393,14 +393,14 @@ func (m *kubeGenericRuntimeManager) podSandboxChanged(pod *api.Pod, podStatus *k
readySandboxCount := 0
for _, s := range podStatus.SandboxStatuses {
if s.GetState() == runtimeApi.PodSandBoxState_READY {
if s.GetState() == runtimeApi.PodSandboxState_SANDBOX_READY {
readySandboxCount++
}
}
// Needs to create a new sandbox when readySandboxCount > 1 or the ready sandbox is not the latest one.
sandboxStatus := podStatus.SandboxStatuses[0]
if readySandboxCount > 1 || sandboxStatus.GetState() != runtimeApi.PodSandBoxState_READY {
if readySandboxCount > 1 || sandboxStatus.GetState() != runtimeApi.PodSandboxState_SANDBOX_READY {
glog.V(2).Infof("No ready sandbox for pod %q can be found. Need to start a new one", format.Pod(pod))
return true, sandboxStatus.Metadata.GetAttempt() + 1, sandboxStatus.GetId()
}
......@@ -865,7 +865,7 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
sandboxStatuses[idx] = podSandboxStatus
// Only get pod IP from latest sandbox
if idx == 0 && podSandboxStatus.GetState() == runtimeApi.PodSandBoxState_READY {
if idx == 0 && podSandboxStatus.GetState() == runtimeApi.PodSandboxState_SANDBOX_READY {
podIP = m.determinePodSandboxIP(namespace, name, podSandboxStatus)
}
}
......
......@@ -66,7 +66,7 @@ type sandboxTemplate struct {
pod *api.Pod
attempt uint32
createdAt int64
state runtimeApi.PodSandBoxState
state runtimeApi.PodSandboxState
}
// containerTemplate is a container template to create fake container.
......@@ -86,7 +86,7 @@ func makeAndSetFakePod(t *testing.T, m *kubeGenericRuntimeManager, fakeRuntime *
sandbox := makeFakePodSandbox(t, m, sandboxTemplate{
pod: pod,
createdAt: fakeCreatedAt,
state: runtimeApi.PodSandBoxState_READY,
state: runtimeApi.PodSandboxState_SANDBOX_READY,
})
var containers []*apitest.FakeContainer
......@@ -95,7 +95,7 @@ func makeAndSetFakePod(t *testing.T, m *kubeGenericRuntimeManager, fakeRuntime *
pod: pod,
container: c,
createdAt: fakeCreatedAt,
state: runtimeApi.ContainerState_RUNNING,
state: runtimeApi.ContainerState_CONTAINER_RUNNING,
}
}
for i := range pod.Spec.Containers {
......@@ -509,10 +509,10 @@ func TestKillPod(t *testing.T) {
assert.Equal(t, 2, len(fakeRuntime.Containers))
assert.Equal(t, 1, len(fakeRuntime.Sandboxes))
for _, sandbox := range fakeRuntime.Sandboxes {
assert.Equal(t, runtimeApi.PodSandBoxState_NOTREADY, sandbox.GetState())
assert.Equal(t, runtimeApi.PodSandboxState_SANDBOX_NOTREADY, sandbox.GetState())
}
for _, c := range fakeRuntime.Containers {
assert.Equal(t, runtimeApi.ContainerState_EXITED, c.GetState())
assert.Equal(t, runtimeApi.ContainerState_CONTAINER_EXITED, c.GetState())
}
}
......@@ -550,10 +550,10 @@ func TestSyncPod(t *testing.T) {
assert.Equal(t, 2, len(fakeImage.Images))
assert.Equal(t, 1, len(fakeRuntime.Sandboxes))
for _, sandbox := range fakeRuntime.Sandboxes {
assert.Equal(t, runtimeApi.PodSandBoxState_READY, sandbox.GetState())
assert.Equal(t, runtimeApi.PodSandboxState_SANDBOX_READY, sandbox.GetState())
}
for _, c := range fakeRuntime.Containers {
assert.Equal(t, runtimeApi.ContainerState_RUNNING, c.GetState())
assert.Equal(t, runtimeApi.ContainerState_CONTAINER_RUNNING, c.GetState())
}
}
......@@ -575,11 +575,11 @@ func TestPruneInitContainers(t *testing.T) {
}
templates := []containerTemplate{
{pod: pod, container: &init1, attempt: 2, createdAt: 2, state: runtimeApi.ContainerState_EXITED},
{pod: pod, container: &init1, attempt: 1, createdAt: 1, state: runtimeApi.ContainerState_EXITED},
{pod: pod, container: &init2, attempt: 1, createdAt: 1, state: runtimeApi.ContainerState_EXITED},
{pod: pod, container: &init2, attempt: 0, createdAt: 0, state: runtimeApi.ContainerState_EXITED},
{pod: pod, container: &init1, attempt: 0, createdAt: 0, state: runtimeApi.ContainerState_EXITED},
{pod: pod, container: &init1, attempt: 2, createdAt: 2, state: runtimeApi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init1, attempt: 1, createdAt: 1, state: runtimeApi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init2, attempt: 1, createdAt: 1, state: runtimeApi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init2, attempt: 0, createdAt: 0, state: runtimeApi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init1, attempt: 0, createdAt: 0, state: runtimeApi.ContainerState_CONTAINER_EXITED},
}
fakes := makeFakeContainers(t, m, templates)
fakeRuntime.SetFakeContainers(fakes)
......
......@@ -153,7 +153,7 @@ func generatePodSandboxLinuxConfig(pod *api.Pod, cgroupParent string) *runtimeAp
func (m *kubeGenericRuntimeManager) getKubeletSandboxes(all bool) ([]*runtimeApi.PodSandbox, error) {
var filter *runtimeApi.PodSandboxFilter
if !all {
readyState := runtimeApi.PodSandBoxState_READY
readyState := runtimeApi.PodSandboxState_SANDBOX_READY
filter = &runtimeApi.PodSandboxFilter{
State: &readyState,
}
......@@ -195,7 +195,7 @@ func (m *kubeGenericRuntimeManager) determinePodSandboxIP(podNamespace, podName
// getPodSandboxID gets the sandbox id by podUID and returns ([]sandboxID, error).
// Param state could be nil in order to get all sandboxes belonging to same pod.
func (m *kubeGenericRuntimeManager) getSandboxIDByPodUID(podUID string, state *runtimeApi.PodSandBoxState) ([]string, error) {
func (m *kubeGenericRuntimeManager) getSandboxIDByPodUID(podUID string, state *runtimeApi.PodSandboxState) ([]string, error) {
filter := &runtimeApi.PodSandboxFilter{
State: state,
LabelSelector: map[string]string{types.KubernetesPodUIDLabel: podUID},
......
......@@ -88,13 +88,13 @@ type fakeContainer struct {
}
func (c *fakeContainer) Start() {
c.State = runtimeApi.ContainerState_RUNNING
c.State = runtimeApi.ContainerState_CONTAINER_RUNNING
c.Status.State = &c.State
}
func (c *fakeContainer) Stop() {
c.State = runtimeApi.ContainerState_EXITED
c.State = runtimeApi.ContainerState_CONTAINER_EXITED
c.Status.State = &c.State
......@@ -135,11 +135,11 @@ func (r *FakeRuntime) StartContainer(id string) error {
return ErrContainerNotFound
}
switch c.State {
case runtimeApi.ContainerState_EXITED:
case runtimeApi.ContainerState_CONTAINER_EXITED:
fallthrough
case runtimeApi.ContainerState_CREATED:
case runtimeApi.ContainerState_CONTAINER_CREATED:
c.Start()
case runtimeApi.ContainerState_UNKNOWN:
case runtimeApi.ContainerState_CONTAINER_UNKNOWN:
// TODO(tmrts): add timeout to Start API or generalize timeout somehow
//<-time.After(time.Duration(timeout) * time.Second)
fallthrough
......@@ -157,9 +157,9 @@ func (r *FakeRuntime) StopContainer(id string, timeout int64) error {
}
switch c.State {
case runtimeApi.ContainerState_RUNNING:
c.State = runtimeApi.ContainerState_EXITED // This state might not be the best one
case runtimeApi.ContainerState_UNKNOWN:
case runtimeApi.ContainerState_CONTAINER_RUNNING:
c.State = runtimeApi.ContainerState_CONTAINER_EXITED // This state might not be the best one
case runtimeApi.ContainerState_CONTAINER_UNKNOWN:
<-time.After(time.Duration(timeout) * time.Second)
fallthrough
default:
......@@ -214,7 +214,7 @@ func (r *FakeRuntime) ExecSync(containerID string, cmd []string, timeout time.Du
}
// TODO(tmrts): Validate the assumption that container has to be running for exec to work.
if c.State != runtimeApi.ContainerState_RUNNING {
if c.State != runtimeApi.ContainerState_CONTAINER_RUNNING {
return nil, nil, ErrInvalidContainerStateTransition
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment