Merge pull request #136278 from AutuSnow/fix/kubelet/WaitForAllPodsUnmount

fix(kubelet):resolve loop variable capture bug in WaitForAllPodsUnmount
This commit is contained in:
Kubernetes Prow Robot
2026-01-16 22:21:17 +05:30
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -516,6 +516,7 @@ func (vm *volumeManager) WaitForAllPodsUnmount(ctx context.Context, pods []*v1.P
funcs := make([]func() error, 0, len(pods))
for _, pod := range pods {
pod := pod
funcs = append(funcs, func() error {
return vm.WaitForUnmount(ctx, pod)
})

View File

@@ -743,6 +743,14 @@ func TestWaitForAllPodsUnmount(t *testing.T) {
require.ErrorAs(t, err, &aggErr, "Expected error to be an Aggregate error")
errs := aggErr.Errors()
require.Len(t, errs, test.numPods, "Expected %d errors but got %d", test.numPods, len(errs))
// Verify that each pod's volume name appears in the error messages,
// which proves different pods are being processed
errString := err.Error()
for i := 0; i < test.numPods; i++ {
volumeName := fmt.Sprintf("fake/fake-device-%d", i)
require.Contains(t, errString, volumeName, "Expected error to contain volume name %s for pod-%d", volumeName, i)
}
} else {
require.NoError(t, err, "Expected no error")
}