osd: replace dot with dash in pvc names
The volume names of a pod must follow the standard naming convention
which does not allow periods in the name. Since the device set name
is used as the pvc name and then the volume name to attach to the osd
prepare job, we must sanitize the name for the invalid character
and replace it.
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 4a70d3489d)
This commit is contained in:
1 parent
67e5bc28e3
commit
32ae0529d2
2 files changed
+15
No files matched your search
@@ -290,5 +290,6 @@ func legacyDeviceSetPVCID(deviceSetName string, setIndex int) string {
|
||||
// It includes the pvcTemplateName in it
|
||||
func deviceSetPVCID(deviceSetName, pvcTemplateName string, setIndex int) string {
|
||||
cleanName := strings.Replace(pvcTemplateName, " ", "-", -1)
|
||||
deviceSetName = strings.Replace(deviceSetName, ".", "-", -1)
|
||||
return fmt.Sprintf("%s-%s-%d", deviceSetName, cleanName, setIndex)
|
||||
}
|
||||
@@ -270,3 +270,17 @@ func TestPrepareDeviceSetsWithCrushParams(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(pvcs.Items))
|
||||
}
|
||||
|
||||
func TestPVCName(t *testing.T) {
|
||||
id := deviceSetPVCID("mydeviceset", "a", 0)
|
||||
assert.Equal(t, "mydeviceset-a-0", id)
|
||||
|
||||
id = deviceSetPVCID("mydeviceset", "a", 10)
|
||||
assert.Equal(t, "mydeviceset-a-10", id)
|
||||
|
||||
id = deviceSetPVCID("device-set", "a", 10)
|
||||
assert.Equal(t, "device-set-a-10", id)
|
||||
|
||||
id = deviceSetPVCID("device.set.with.dots", "b", 10)
|
||||
assert.Equal(t, "device-set-with-dots-b-10", id)
|
||||
}
|
||||
Reference in new issue
Block a user