From 79ea511ec6e0e585f911a0569d2e5dd2381540ae Mon Sep 17 00:00:00 2001 From: Harsh Desai Date: Wed, 7 Feb 2018 22:13:00 -0800 Subject: [PATCH] Pass pvc namespace and annotations to Portworx Create API Closes #59606 Signed-off-by: Harsh Desai --- pkg/volume/portworx/portworx_util.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/volume/portworx/portworx_util.go b/pkg/volume/portworx/portworx_util.go index 60677df2c9a..fbf4b883784 100644 --- a/pkg/volume/portworx/portworx_util.go +++ b/pkg/volume/portworx/portworx_util.go @@ -30,12 +30,13 @@ import ( ) const ( - osdMgmtPort = "9001" - osdDriverVersion = "v1" - pxdDriverName = "pxd" - pvcClaimLabel = "pvc" - pxServiceName = "portworx-service" - pxDriverName = "pxd-sched" + osdMgmtPort = "9001" + osdDriverVersion = "v1" + pxdDriverName = "pxd" + pvcClaimLabel = "pvc" + pvcNamespaceLabel = "namespace" + pxServiceName = "portworx-service" + pxDriverName = "pxd-sched" ) type PortworxVolumeUtil struct { @@ -80,9 +81,20 @@ func (util *PortworxVolumeUtil) CreateVolume(p *portworxVolumeProvisioner) (stri // Add claim Name as a part of Portworx Volume Labels locator.VolumeLabels[pvcClaimLabel] = p.options.PVC.Name + locator.VolumeLabels[pvcNamespaceLabel] = p.options.PVC.Namespace + + for k, v := range p.options.PVC.Annotations { + if _, present := spec.VolumeLabels[k]; present { + glog.Warningf("not saving annotation: %s=%s in spec labels due to an existing key", k, v) + continue + } + spec.VolumeLabels[k] = v + } + volumeID, err := driver.Create(locator, source, spec) if err != nil { glog.Errorf("Error creating Portworx Volume : %v", err) + return "", 0, nil, err } glog.Infof("Successfully created Portworx volume for PVC: %v", p.options.PVC.Name)