From 5bd0b5d841823095826fbca5f308a8da962a9b4e Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Fri, 26 Oct 2018 17:45:42 +0530 Subject: [PATCH 1/2] GlusterFS: Use pvc uid instead of pvc name in glusterfs endpoint name. At present, endpoints and services are created for glusterfs pvcs are in form of glusterfs-dynamic- however this could cause issue if user deletes a PVC and immediately creates a new one with the same name, PV controller will try to delete the old PV and its endpoint and at the same the controller will try to create new PV and the same endpoint. Depending on which event reaches the controller first, it may create new PV, check that endpoints exists, then delete the old PVC and delete endpoints already used by the new PV. This patch changes the endpoint/service name to below format: `glusterfs-dynamic-`. By the uniqueness of UUID, above mentioned issue will no longer be present. Signed-off-by: Humble Chirammal --- pkg/volume/glusterfs/glusterfs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 9b6c7564428..6ee974d6f5b 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -822,11 +822,11 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolum return nil, 0, "", fmt.Errorf("failed to get cluster nodes for volume %s: %v", volume, err) } - // The 'endpointname' is created in form of 'glusterfs-dynamic-'. + // The 'endpointname' is created in form of 'glusterfs-dynamic-'. // createEndpointService() checks for this 'endpoint' existence in PVC's namespace and // If not found, it create an endpoint and service using the IPs we dynamically picked at time // of volume creation. - epServiceName := dynamicEpSvcPrefix + p.options.PVC.Name + epServiceName := dynamicEpSvcPrefix + string(p.options.PVC.UID) epNamespace := p.options.PVC.Namespace endpoint, service, err := p.createEndpointService(epNamespace, epServiceName, dynamicHostIps, p.options.PVC.Name) if err != nil { From a6759a7b22c8577f72b64ea0a3797ae15e552633 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Fri, 26 Oct 2018 20:01:19 +0530 Subject: [PATCH 2/2] Fix a typo in source code comment Signed-off-by: Humble Chirammal --- pkg/volume/glusterfs/glusterfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 6ee974d6f5b..7b7537cb034 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -824,7 +824,7 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolum // The 'endpointname' is created in form of 'glusterfs-dynamic-'. // createEndpointService() checks for this 'endpoint' existence in PVC's namespace and - // If not found, it create an endpoint and service using the IPs we dynamically picked at time + // if not found, it create an endpoint and service using the IPs we dynamically picked at time // of volume creation. epServiceName := dynamicEpSvcPrefix + string(p.options.PVC.UID) epNamespace := p.options.PVC.Namespace