-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reduce the volume name gap with external-provisioner #178
Conversation
Hi @smileusd. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
controller/controller.go
Outdated
func (ctrl *ProvisionController) makeVolumeName(pvcUID string) (string, error) { | ||
// create persistent name based on a volumeNamePrefix and volumeNameUUIDLength | ||
// of PVC's UID | ||
if len(ctrl.volumeNamePrefix) == 0 { | ||
return "", fmt.Errorf("Volume name prefix cannot be of length 0") | ||
} | ||
if ctrl.volumeNameUUIDLength == 0 { | ||
return "", fmt.Errorf("Volume length cannot be 0") | ||
} | ||
if len(pvcUID) == 0 { | ||
return "", fmt.Errorf("corrupted PVC object, it is missing UID") | ||
} | ||
if ctrl.volumeNameUUIDLength == -1 { | ||
// Default behavior is to not truncate or remove dashes | ||
return fmt.Sprintf("%s-%s", ctrl.volumeNamePrefix, pvcUID), nil | ||
} | ||
// Else we remove all dashes from UUID and truncate to volumeNameUUIDLength | ||
return fmt.Sprintf("%s-%s", ctrl.volumeNamePrefix, strings.Replace(string(pvcUID), "-", "", -1)[0:ctrl.volumeNameUUIDLength]), nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to keep this weird function in the external-provisioner and here just provide a configurable callback stored in ProvisionController
:
type VolumeNameHook func(claim *v1.PersistentVolumeClaim) string
type ProvisionController struct {
...
volumeNameHook VolumeNameHook
}
...
func VolumeName(hook VolumeNameHook) func(*ProvisionController) error {
return func(c *ProvisionController) error {
if c.HasRun() {
return errRuntime
}
c.volumeNameHook = hook
return nil
}
}
With the default value getProvisionedVolumeNameForClaim
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your suggestion. I try to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Please check @jsafrane
/ok-to-test |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jsafrane, smileusd The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@jsafrane Thank you! |
This pr is to reduce the gap with the external-provisioner pv name generation at https://github.com/kubernetes-csi/external-provisioner/blob/0f8b1662e25f37675da1f82acb78cd820b359419/pkg/controller/controller.go#L626
There is a potential bug if user not use default prefix or length to generate the pv name. There is a unexpected error.
/kind bug
/sig storage