mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +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))
|
||||
|
||||
// Remove pod
|
||||
// TODO: this may not be threadsafe (technically waitForVolumeUnmount)
|
||||
kubelet.podWorkers.(*fakePodWorkers).removeRuntime = map[types.UID]bool{pod.UID: true}
|
||||
// TODO: technically waitForVolumeUnmount
|
||||
kubelet.podWorkers.(*fakePodWorkers).setPodRuntimeBeRemoved(pod.UID)
|
||||
kubelet.podManager.SetPods([]*v1.Pod{})
|
||||
|
||||
assert.NoError(t, kubelet.volumeManager.WaitForUnmount(pod))
|
||||
@ -504,7 +504,7 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
|
||||
1 /* expectedSetUpCallCount */, testKubelet.volumePlugin))
|
||||
|
||||
// Remove pod
|
||||
kubelet.podWorkers.(*fakePodWorkers).removeRuntime = map[types.UID]bool{pod.UID: true}
|
||||
kubelet.podWorkers.(*fakePodWorkers).setPodRuntimeBeRemoved(pod.UID)
|
||||
kubelet.podManager.SetPods([]*v1.Pod{})
|
||||
|
||||
assert.NoError(t, waitForVolumeUnmount(kubelet.volumeManager, pod))
|
||||
|
@ -111,6 +111,11 @@ func (f *fakePodWorkers) ShouldPodRuntimeBeRemoved(uid types.UID) bool {
|
||||
defer f.statusLock.Unlock()
|
||||
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 {
|
||||
f.statusLock.Lock()
|
||||
defer f.statusLock.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user