mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-05 23:44:21 +01:00
Merge pull request #1507 from bergwolf/state
split sandbox/container state
This commit is contained in:
@@ -102,7 +102,7 @@ func delete(ctx context.Context, containerID string, force bool) error {
|
||||
}
|
||||
|
||||
forceStop := false
|
||||
if oci.StateToOCIState(status.State) == oci.StateRunning {
|
||||
if oci.StateToOCIState(status.State.State) == oci.StateRunning {
|
||||
if !force {
|
||||
return fmt.Errorf("Container still running, should be stopped")
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func deleteSandbox(ctx context.Context, sandboxID string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if oci.StateToOCIState(status.State) != oci.StateStopped {
|
||||
if oci.StateToOCIState(status.State.State) != oci.StateStopped {
|
||||
if _, err := vci.StopSandbox(ctx, sandboxID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func TestDeleteSandbox(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "ready",
|
||||
},
|
||||
}, nil
|
||||
@@ -185,7 +185,7 @@ func TestDeleteSandbox(t *testing.T) {
|
||||
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
|
||||
return vc.SandboxStatus{
|
||||
ID: sandbox.ID(),
|
||||
State: types.State{
|
||||
State: types.SandboxState{
|
||||
State: types.StateReady,
|
||||
},
|
||||
}, nil
|
||||
@@ -246,7 +246,7 @@ func TestDeleteInvalidContainerType(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: "InvalidType",
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "created",
|
||||
},
|
||||
}, nil
|
||||
@@ -285,7 +285,7 @@ func TestDeleteSandboxRunning(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "running",
|
||||
},
|
||||
}, nil
|
||||
@@ -303,7 +303,7 @@ func TestDeleteSandboxRunning(t *testing.T) {
|
||||
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
|
||||
return vc.SandboxStatus{
|
||||
ID: sandbox.ID(),
|
||||
State: types.State{
|
||||
State: types.SandboxState{
|
||||
State: types.StateRunning,
|
||||
},
|
||||
}, nil
|
||||
@@ -365,7 +365,7 @@ func TestDeleteRunningContainer(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "running",
|
||||
},
|
||||
}, nil
|
||||
@@ -448,7 +448,7 @@ func TestDeleteContainer(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "ready",
|
||||
},
|
||||
}, nil
|
||||
@@ -548,7 +548,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: "ready",
|
||||
},
|
||||
}, nil
|
||||
@@ -557,7 +557,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
|
||||
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
|
||||
return vc.SandboxStatus{
|
||||
ID: sandbox.ID(),
|
||||
State: types.State{
|
||||
State: types.SandboxState{
|
||||
State: types.StateReady,
|
||||
},
|
||||
}, nil
|
||||
|
||||
@@ -112,7 +112,7 @@ func TestEventsCLISuccessful(t *testing.T) {
|
||||
Annotations: map[string]string{
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
},
|
||||
}, nil
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestExecuteErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
|
||||
return newSingleContainerStatus(testContainerID, types.State{}, annotations), nil
|
||||
return newSingleContainerStatus(testContainerID, types.ContainerState{}, annotations), nil
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@@ -100,7 +100,7 @@ func TestExecuteErrors(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
containerState := types.State{}
|
||||
containerState := types.ContainerState{}
|
||||
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
|
||||
return newSingleContainerStatus(testContainerID, containerState, annotations), nil
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func TestExecuteErrors(t *testing.T) {
|
||||
assert.False(vcmock.IsMockError(err))
|
||||
|
||||
// Container paused
|
||||
containerState = types.State{
|
||||
containerState = types.ContainerState{
|
||||
State: types.StatePaused,
|
||||
}
|
||||
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
|
||||
@@ -122,7 +122,7 @@ func TestExecuteErrors(t *testing.T) {
|
||||
assert.False(vcmock.IsMockError(err))
|
||||
|
||||
// Container stopped
|
||||
containerState = types.State{
|
||||
containerState = types.ContainerState{
|
||||
State: types.StateStopped,
|
||||
}
|
||||
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
|
||||
@@ -159,7 +159,7 @@ func TestExecuteErrorReadingProcessJson(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestExecuteErrorOpeningConsole(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func TestExecuteWithFlags(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ func TestExecuteWithFlagsDetached(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ func TestExecuteWithInvalidProcessJson(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ func TestExecuteWithValidProcessJson(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ func TestExecuteWithEmptyEnvironmentValue(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestProcessSignal(t *testing.T) {
|
||||
func testKillCLIFunctionTerminationSignalSuccessful(t *testing.T, sig string) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestKillCLIFunctionSigtermSuccessful(t *testing.T) {
|
||||
func TestKillCLIFunctionNotTerminationSignalSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestKillCLIFunctionNotTerminationSignalSuccessful(t *testing.T) {
|
||||
func TestKillCLIFunctionNoSignalSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ func TestKillCLIFunctionNoSignalSuccessful(t *testing.T) {
|
||||
func TestKillCLIFunctionEnableAllSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func TestKillCLIFunctionContainerNotExistFailure(t *testing.T) {
|
||||
func TestKillCLIFunctionInvalidSignalFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ func TestKillCLIFunctionInvalidSignalFailure(t *testing.T) {
|
||||
func TestKillCLIFunctionStatePausedSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StatePaused,
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ func TestKillCLIFunctionStatePausedSuccessful(t *testing.T) {
|
||||
func TestKillCLIFunctionInvalidStateStoppedFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateStopped,
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ func TestKillCLIFunctionInvalidStateStoppedFailure(t *testing.T) {
|
||||
func TestKillCLIFunctionKillContainerFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ func TestKillCLIFunctionKillContainerFailure(t *testing.T) {
|
||||
func TestKillCLIFunctionInvalidStateStoppedAllSuccess(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateStopped,
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ func writeOCIConfigFile(spec oci.CompatOCISpec, configPath string) error {
|
||||
return ioutil.WriteFile(configPath, bytes, testFileMode)
|
||||
}
|
||||
|
||||
func newSingleContainerStatus(containerID string, containerState types.State, annotations map[string]string) vc.ContainerStatus {
|
||||
func newSingleContainerStatus(containerID string, containerState types.ContainerState, annotations map[string]string) vc.ContainerStatus {
|
||||
return vc.ContainerStatus{
|
||||
ID: containerID,
|
||||
State: containerState,
|
||||
|
||||
@@ -39,7 +39,7 @@ var (
|
||||
func TestNetworkCliFunction(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
func TestPauseCLIFunctionSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestPauseCLIFunctionContainerNotExistFailure(t *testing.T) {
|
||||
func TestPauseCLIFunctionPauseContainerFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestPauseCLIFunctionPauseContainerFailure(t *testing.T) {
|
||||
func TestResumeCLIFunctionSuccessful(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestResumeCLIFunctionContainerNotExistFailure(t *testing.T) {
|
||||
func TestResumeCLIFunctionPauseContainerFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
state := types.State{
|
||||
state := types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestPSSuccessful(t *testing.T) {
|
||||
|
||||
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
|
||||
return vc.ContainerStatus{
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
},
|
||||
ID: sandbox.ID(),
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestUpdateCLIFailure(t *testing.T) {
|
||||
Annotations: map[string]string{
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
},
|
||||
}, nil
|
||||
@@ -168,7 +168,7 @@ func TestUpdateCLISuccessful(t *testing.T) {
|
||||
Annotations: map[string]string{
|
||||
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
|
||||
},
|
||||
State: types.State{
|
||||
State: types.ContainerState{
|
||||
State: types.StateRunning,
|
||||
},
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user