Merge pull request #76184 from humblec/pvc

Use pvc uid in endpoint/service label
This commit is contained in:
Kubernetes Prow Robot 2019-04-09 11:21:14 -07:00 committed by GitHub
commit 454666bca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -865,7 +865,7 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsPersi
epServiceName = p.provisionerConfig.customEpNamePrefix + "-" + string(p.options.PVC.UID)
}
epNamespace := p.options.PVC.Namespace
endpoint, service, err := p.createEndpointService(epNamespace, epServiceName, dynamicHostIps, p.options.PVC.Name)
endpoint, service, err := p.createEndpointService(epNamespace, epServiceName, dynamicHostIps, p.options.PVC)
if err != nil {
klog.Errorf("failed to create endpoint/service %v/%v: %v", epNamespace, epServiceName, err)
deleteErr := cli.VolumeDelete(volume.Id)
@ -887,7 +887,13 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsPersi
// exist for the given namespace, PVC name, endpoint name, and
// set of IPs. I.e. the endpoint or service is only created
// if it does not exist yet.
func (p *glusterfsVolumeProvisioner) createEndpointService(namespace string, epServiceName string, hostips []string, pvcname string) (endpoint *v1.Endpoints, service *v1.Service, err error) {
func (p *glusterfsVolumeProvisioner) createEndpointService(namespace string, epServiceName string, hostips []string, pvc *v1.PersistentVolumeClaim) (endpoint *v1.Endpoints, service *v1.Service, err error) {
pvcNameOrID := ""
if len(pvc.Name) >= 63 {
pvcNameOrID = string(pvc.UID)
} else {
pvcNameOrID = pvc.Name
}
addrlist := make([]v1.EndpointAddress, len(hostips))
for i, v := range hostips {
@ -898,7 +904,7 @@ func (p *glusterfsVolumeProvisioner) createEndpointService(namespace string, epS
Namespace: namespace,
Name: epServiceName,
Labels: map[string]string{
"gluster.kubernetes.io/provisioned-for-pvc": pvcname,
"gluster.kubernetes.io/provisioned-for-pvc": pvcNameOrID,
},
},
Subsets: []v1.EndpointSubset{{
@ -924,7 +930,7 @@ func (p *glusterfsVolumeProvisioner) createEndpointService(namespace string, epS
Name: epServiceName,
Namespace: namespace,
Labels: map[string]string{
"gluster.kubernetes.io/provisioned-for-pvc": pvcname,
"gluster.kubernetes.io/provisioned-for-pvc": pvcNameOrID,
},
},
Spec: v1.ServiceSpec{