Merge pull request #67745 from feiskyer/choose-zones
Automatic merge from submit-queue (batch tested with PRs 67745, 67432, 67569, 67825, 67943). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. Fix panic when choosing zone or zones for volume **What this PR does / why we need it**: Fix panic when choosing zone or zones for volume, so that zoneSlice won't divide by zero now. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` cc @ddebroy @andyzhangx
This commit is contained in:
@@ -647,6 +647,17 @@ func TestChooseZoneForVolume(t *testing.T) {
|
||||
VolumeName: "medium-henley--4",
|
||||
Expected: "c", // hash("") + 4 == 2 mod 3
|
||||
},
|
||||
// Test for no zones
|
||||
{
|
||||
Zones: sets.NewString(),
|
||||
VolumeName: "medium-henley--1",
|
||||
Expected: "",
|
||||
},
|
||||
{
|
||||
Zones: nil,
|
||||
VolumeName: "medium-henley--2",
|
||||
Expected: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -992,6 +1003,17 @@ func TestChooseZonesForVolume(t *testing.T) {
|
||||
NumZones: 3,
|
||||
Expected: sets.NewString("a" /* hash("henley") == 0 + 3 + 6(startingIndex) */, "b", "c"),
|
||||
},
|
||||
// Test for no zones
|
||||
{
|
||||
Zones: sets.NewString(),
|
||||
VolumeName: "henley-1",
|
||||
Expected: sets.NewString(),
|
||||
},
|
||||
{
|
||||
Zones: nil,
|
||||
VolumeName: "henley-2",
|
||||
Expected: sets.NewString(),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user