Merge pull request #27970 from jingxu97/restartKubelet-6-22

Automatic merge from submit-queue

Add volume reconstruct/cleanup logic in kubelet volume manager

Currently kubelet volume management works on the concept of desired
and actual world of states. The volume manager periodically compares the
two worlds and perform volume mount/unmount and/or attach/detach
operations. When kubelet restarts, the cache of those two worlds are
gone. Although desired world can be recovered through apiserver, actual
world can not be recovered which may cause some volumes cannot be cleaned
up if their information is deleted by apiserver. This change adds the
reconstruction of the actual world by reading the pod directories from
disk. The reconstructed volume information is added to both desired
world and actual world if it cannot be found in either world. The rest
logic would be as same as before, desired world populator may clean up
the volume entry if it is no longer in apiserver, and then volume
manager should invoke unmount to clean it up.

Fixes https://github.com/kubernetes/kubernetes/issues/27653
This commit is contained in:
Kubernetes Submit Queue
2016-08-15 13:48:43 -07:00
committed by GitHub
46 changed files with 999 additions and 247 deletions

View File

@@ -248,7 +248,8 @@ func newTestKubeletWithImageList(
fakeKubeClient,
kubelet.volumePluginMgr,
fakeRuntime,
kubelet.mounter)
kubelet.mounter,
kubelet.getPodsDir())
if err != nil {
t.Fatalf("failed to initialize volume manager: %v", err)
}
@@ -404,8 +405,7 @@ func TestVolumeAttachAndMountControllerDisabled(t *testing.T) {
},
})
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(stopCh)
stopCh := runVolumeManager(kubelet)
defer func() {
close(stopCh)
}()
@@ -474,8 +474,7 @@ func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) {
},
})
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(stopCh)
stopCh := runVolumeManager(kubelet)
defer func() {
close(stopCh)
}()
@@ -603,8 +602,7 @@ func TestVolumeAttachAndMountControllerEnabled(t *testing.T) {
},
})
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(stopCh)
stopCh := runVolumeManager(kubelet)
defer func() {
close(stopCh)
}()
@@ -697,8 +695,7 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
},
})
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(stopCh)
stopCh := runVolumeManager(kubelet)
defer func() {
close(stopCh)
}()
@@ -856,8 +853,7 @@ func TestPodVolumesExist(t *testing.T) {
},
}
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(stopCh)
stopCh := runVolumeManager(kubelet)
defer func() {
close(stopCh)
}()
@@ -3939,3 +3935,9 @@ func simulateVolumeInUseUpdate(
}
}
}
func runVolumeManager(kubelet *Kubelet) chan struct{} {
stopCh := make(chan struct{})
go kubelet.volumeManager.Run(kubelet.sourcesReady, stopCh)
return stopCh
}