Merge pull request #117079 from qingwave/sort-volumes

kubelet/volumemanager: sort unmounted volumes in error message
This commit is contained in:
Kubernetes Prow Robot 2023-06-07 18:52:12 -07:00 committed by GitHub
commit 89bfdf0276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -504,6 +504,7 @@ func (vm *volumeManager) getUnattachedVolumes(uniquePodName types.UniquePodName)
unattachedVolumes = append(unattachedVolumes, volumeToMount.OuterVolumeSpecName) unattachedVolumes = append(unattachedVolumes, volumeToMount.OuterVolumeSpecName)
} }
} }
sort.Strings(unattachedVolumes)
return unattachedVolumes return unattachedVolumes
} }
@ -551,6 +552,8 @@ func filterUnmountedVolumes(mountedVolumes sets.String, expectedVolumes []string
unmountedVolumes = append(unmountedVolumes, expectedVolume) unmountedVolumes = append(unmountedVolumes, expectedVolume)
} }
} }
sort.Strings(unmountedVolumes)
return unmountedVolumes return unmountedVolumes
} }

View File

@ -164,10 +164,18 @@ func TestWaitForAttachAndMountError(t *testing.T) {
Name: "vol2", Name: "vol2",
MountPath: "/vol2", MountPath: "/vol2",
}, },
{
Name: "vol02",
MountPath: "/vol02",
},
{ {
Name: "vol3", Name: "vol3",
MountPath: "/vol3", MountPath: "/vol3",
}, },
{
Name: "vol03",
MountPath: "/vol03",
},
}, },
}, },
}, },
@ -184,12 +192,24 @@ func TestWaitForAttachAndMountError(t *testing.T) {
RBD: &v1.RBDVolumeSource{}, RBD: &v1.RBDVolumeSource{},
}, },
}, },
{
Name: "vol02",
VolumeSource: v1.VolumeSource{
RBD: &v1.RBDVolumeSource{},
},
},
{ {
Name: "vol3", Name: "vol3",
VolumeSource: v1.VolumeSource{ VolumeSource: v1.VolumeSource{
AzureDisk: &v1.AzureDiskVolumeSource{}, AzureDisk: &v1.AzureDiskVolumeSource{},
}, },
}, },
{
Name: "vol03",
VolumeSource: v1.VolumeSource{
AzureDisk: &v1.AzureDiskVolumeSource{},
},
},
}, },
}, },
} }
@ -208,7 +228,7 @@ func TestWaitForAttachAndMountError(t *testing.T) {
t.Errorf("Expected error, got none") t.Errorf("Expected error, got none")
} }
if !strings.Contains(err.Error(), if !strings.Contains(err.Error(),
"unattached volumes=[vol2], failed to process volumes=[vol3]") { "unattached volumes=[vol02 vol2], failed to process volumes=[vol03 vol3]") {
t.Errorf("Unexpected error info: %v", err) t.Errorf("Unexpected error info: %v", err)
} }
} }