mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
dockertools: fix error exited container list in fake docker client
This commit is contained in:
parent
96eeb812ff
commit
98283d894c
@ -297,6 +297,8 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f.Stopped = append(f.Stopped, id)
|
f.Stopped = append(f.Stopped, id)
|
||||||
|
// Container status should be Updated before container moved to ExitedContainerList
|
||||||
|
f.updateContainerStatus(id, statusExitedPrefix)
|
||||||
var newList []docker.APIContainers
|
var newList []docker.APIContainers
|
||||||
for _, container := range f.ContainerList {
|
for _, container := range f.ContainerList {
|
||||||
if container.ID == id {
|
if container.ID == id {
|
||||||
@ -323,7 +325,6 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
|
|||||||
container.State.Running = false
|
container.State.Running = false
|
||||||
}
|
}
|
||||||
f.ContainerMap[id] = container
|
f.ContainerMap[id] = container
|
||||||
f.updateContainerStatus(id, statusExitedPrefix)
|
|
||||||
f.normalSleep(200, 50, 50)
|
f.normalSleep(200, 50, 50)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -333,11 +334,20 @@ func (f *FakeDockerClient) RemoveContainer(opts docker.RemoveContainerOptions) e
|
|||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
f.called = append(f.called, "remove")
|
f.called = append(f.called, "remove")
|
||||||
err := f.popError("remove")
|
err := f.popError("remove")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
f.Removed = append(f.Removed, opts.ID)
|
return err
|
||||||
}
|
}
|
||||||
delete(f.ContainerMap, opts.ID)
|
for i := range f.ExitedContainerList {
|
||||||
return err
|
if f.ExitedContainerList[i].ID == opts.ID {
|
||||||
|
delete(f.ContainerMap, opts.ID)
|
||||||
|
f.ExitedContainerList = append(f.ExitedContainerList[:i], f.ExitedContainerList[i+1:]...)
|
||||||
|
f.Removed = append(f.Removed, opts.ID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// To be a good fake, report error if container is not stopped.
|
||||||
|
return fmt.Errorf("container not stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logs is a test-spy implementation of DockerInterface.Logs.
|
// Logs is a test-spy implementation of DockerInterface.Logs.
|
||||||
|
Loading…
Reference in New Issue
Block a user