mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
Merge pull request #104069 from pacoxu/fix-data-race-104057
fix data race in kubelet volume test: add lock for ut
This commit is contained in:
commit
5724484bda
@ -315,8 +315,8 @@ func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) {
|
|||||||
1 /* expectedSetUpCallCount */, testKubelet.volumePlugin))
|
1 /* expectedSetUpCallCount */, testKubelet.volumePlugin))
|
||||||
|
|
||||||
// Remove pod
|
// Remove pod
|
||||||
// TODO: this may not be threadsafe (technically waitForVolumeUnmount)
|
// TODO: technically waitForVolumeUnmount
|
||||||
kubelet.podWorkers.(*fakePodWorkers).removeRuntime = map[types.UID]bool{pod.UID: true}
|
kubelet.podWorkers.(*fakePodWorkers).setPodRuntimeBeRemoved(pod.UID)
|
||||||
kubelet.podManager.SetPods([]*v1.Pod{})
|
kubelet.podManager.SetPods([]*v1.Pod{})
|
||||||
|
|
||||||
assert.NoError(t, kubelet.volumeManager.WaitForUnmount(pod))
|
assert.NoError(t, kubelet.volumeManager.WaitForUnmount(pod))
|
||||||
@ -504,7 +504,7 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
|
|||||||
1 /* expectedSetUpCallCount */, testKubelet.volumePlugin))
|
1 /* expectedSetUpCallCount */, testKubelet.volumePlugin))
|
||||||
|
|
||||||
// Remove pod
|
// Remove pod
|
||||||
kubelet.podWorkers.(*fakePodWorkers).removeRuntime = map[types.UID]bool{pod.UID: true}
|
kubelet.podWorkers.(*fakePodWorkers).setPodRuntimeBeRemoved(pod.UID)
|
||||||
kubelet.podManager.SetPods([]*v1.Pod{})
|
kubelet.podManager.SetPods([]*v1.Pod{})
|
||||||
|
|
||||||
assert.NoError(t, waitForVolumeUnmount(kubelet.volumeManager, pod))
|
assert.NoError(t, waitForVolumeUnmount(kubelet.volumeManager, pod))
|
||||||
|
@ -111,6 +111,11 @@ func (f *fakePodWorkers) ShouldPodRuntimeBeRemoved(uid types.UID) bool {
|
|||||||
defer f.statusLock.Unlock()
|
defer f.statusLock.Unlock()
|
||||||
return f.removeRuntime[uid]
|
return f.removeRuntime[uid]
|
||||||
}
|
}
|
||||||
|
func (f *fakePodWorkers) setPodRuntimeBeRemoved(uid types.UID) {
|
||||||
|
f.statusLock.Lock()
|
||||||
|
defer f.statusLock.Unlock()
|
||||||
|
f.removeRuntime = map[types.UID]bool{uid: true}
|
||||||
|
}
|
||||||
func (f *fakePodWorkers) ShouldPodContentBeRemoved(uid types.UID) bool {
|
func (f *fakePodWorkers) ShouldPodContentBeRemoved(uid types.UID) bool {
|
||||||
f.statusLock.Lock()
|
f.statusLock.Lock()
|
||||||
defer f.statusLock.Unlock()
|
defer f.statusLock.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user