Skip to content

Commit ed71663

Browse files
author
Mike Cronce
committed
pkg/controller/controller.go: makeVolumeName(): When readable names are enabled, use a hash of the PVC namespace and name in place of the UID, making the entire PV name deterministic
1 parent 4d159a9 commit ed71663

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/controller/controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controller
1818

1919
import (
2020
"context"
21+
"crypto/md5"
2122
"fmt"
2223
"math"
2324
"net"
@@ -403,9 +404,10 @@ func (p *csiProvisioner) makeVolumeName(pvcNamespace, pvcName, pvcUID string) (s
403404
if(len(pvcName) == 0) {
404405
return "", fmt.Errorf("corrupted PVC object, it is missing name")
405406
}
407+
pvcHash := md5.Sum([]byte(pvcNamespace + "/" + pvcName))
406408
pvcNamespace = strings.Replace(pvcNamespace, "-", "", -1)
407409
pvcName = strings.Replace(pvcName, "-", "", -1)
408-
fullName = fmt.Sprintf("%s-%s-%s", pvcNamespace, pvcName, pvcUID)
410+
fullName = fmt.Sprintf("%s-%s-%x", pvcNamespace, pvcName, pvcHash)
409411
} else {
410412
fullName = pvcUID
411413
}

0 commit comments

Comments
 (0)