Skip to content

Commit

Permalink
Change default pvName behavior to non-truncating
Browse files Browse the repository at this point in the history
  • Loading branch information
davidz627 committed Aug 2, 2018
1 parent 6f65060 commit 24d82a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
csiEndpoint = flag.String("csi-address", "/run/csi/socket", "The gRPC endpoint for Target CSI Volume")
connectionTimeout = flag.Duration("connection-timeout", 10*time.Second, "Timeout for waiting for CSI driver socket.")
volumeNamePrefix = flag.String("volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume")
volumeNameUUIDLength = flag.Int("volume-name-uuid-length", 16, "Length in characters for the generated uuid of a created volume")
volumeNameUUIDLength = flag.Int("volume-name-uuid-length", -1, "Length in characters for the generated uuid of a created volume")
showVersion = flag.Bool("version", false, "Show version.")

provisionController *controller.ProvisionController
Expand Down
9 changes: 8 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,14 @@ func makeVolumeName(prefix, pvcUID string, volumeNameUUIDLength int) (string, er
if len(pvcUID) == 0 {
return "", fmt.Errorf("corrupted PVC object, it is missing UID")
}
return fmt.Sprintf("%s-%s", prefix, strings.Replace(string(pvcUID), "-", "", -1)[0:volumeNameUUIDLength]), nil
if volumeNameUUIDLength == -1 {
// Default behavior is to not truncate or remove dashes
return fmt.Sprintf("%s-%s", prefix, pvcUID), nil
} else {
// Else we remove all dashes from UUID and truncate to volumeNameUUIDLength
return fmt.Sprintf("%s-%s", prefix, strings.Replace(string(pvcUID), "-", "", -1)[0:volumeNameUUIDLength]), nil
}

}

func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
Expand Down

0 comments on commit 24d82a9

Please sign in to comment.