mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Restart network container when container's configure is changed.
Fix #2099
This commit is contained in:
parent
652a0ce4db
commit
03958f5049
@ -588,6 +588,14 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
||||
continue
|
||||
}
|
||||
killedContainers[containerID] = empty{}
|
||||
|
||||
// Also kill associated network container
|
||||
if netContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, networkContainerName); found {
|
||||
if err := kl.killContainer(netContainer); err != nil {
|
||||
glog.V(1).Infof("Failed to kill network container %s: %v", netContainer.ID, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check RestartPolicy for container
|
||||
|
@ -559,15 +559,17 @@ func TestSyncPodBadHash(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
verifyCalls(t, fakeDocker, []string{"list", "stop", "list", "create", "start"})
|
||||
verifyCalls(t, fakeDocker, []string{"list", "stop", "stop", "list", "create", "start"})
|
||||
|
||||
// A map interation is used to delete containers, so must not depend on
|
||||
// order here.
|
||||
expectedToStop := map[string]bool{
|
||||
"1234": true,
|
||||
"9876": true,
|
||||
}
|
||||
if len(fakeDocker.Stopped) != 1 ||
|
||||
!expectedToStop[fakeDocker.Stopped[0]] {
|
||||
if len(fakeDocker.Stopped) != 2 ||
|
||||
(!expectedToStop[fakeDocker.Stopped[0]] &&
|
||||
!expectedToStop[fakeDocker.Stopped[1]]) {
|
||||
t.Errorf("Wrong containers were stopped: %v", fakeDocker.Stopped)
|
||||
}
|
||||
}
|
||||
@ -607,15 +609,17 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
verifyCalls(t, fakeDocker, []string{"list", "stop", "list", "create", "start"})
|
||||
verifyCalls(t, fakeDocker, []string{"list", "stop", "stop", "list", "create", "start"})
|
||||
|
||||
// A map interation is used to delete containers, so must not depend on
|
||||
// order here.
|
||||
expectedToStop := map[string]bool{
|
||||
"1234": true,
|
||||
"9876": true,
|
||||
}
|
||||
if len(fakeDocker.Stopped) != 1 ||
|
||||
!expectedToStop[fakeDocker.Stopped[0]] {
|
||||
if len(fakeDocker.Stopped) != 2 ||
|
||||
(!expectedToStop[fakeDocker.Stopped[0]] &&
|
||||
expectedToStop[fakeDocker.Stopped[0]]) {
|
||||
t.Errorf("Wrong containers were stopped: %v", fakeDocker.Stopped)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user