Skip to content

Commit

Permalink
Merge pull request #73 from sbezverk/volume_name_length
Browse files Browse the repository at this point in the history
Fixes issue#72
  • Loading branch information
lpabon authored Apr 19, 2018
2 parents f27faff + e0cb010 commit 1e98c88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func checkDriverState(grpcClient *grpc.ClientConn, timeout time.Duration) (strin
return driverName, nil
}

func makeVolumeName(prefix, pvcUID string) (string, error) {
func makeVolumeName(prefix, pvcUID string, volumeNameUUIDLength int) (string, error) {
// create persistent name based on a volumeNamePrefix and volumeNameUUIDLength
// of PVC's UID
if len(prefix) == 0 {
Expand All @@ -258,7 +258,7 @@ func makeVolumeName(prefix, pvcUID string) (string, error) {
if len(pvcUID) == 0 {
return "", fmt.Errorf("corrupted PVC object, it is missing UID")
}
return fmt.Sprintf("%s-%s", prefix, pvcUID), nil
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 All @@ -271,7 +271,7 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
return nil, err
}

share, err := makeVolumeName(p.volumeNamePrefix, fmt.Sprintf("%s", options.PVC.ObjectMeta.UID))
share, err := makeVolumeName(p.volumeNamePrefix, fmt.Sprintf("%s", options.PVC.ObjectMeta.UID), p.volumeNameUUIDLength)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1e98c88

Please sign in to comment.