From 89b4be57d5c38b21e0f12b2d3c53041dcb6da546 Mon Sep 17 00:00:00 2001 From: kmova Date: Thu, 28 Jun 2018 18:47:25 +0000 Subject: [PATCH 1/2] Pass sts replica scheduling label to apiserver Signed-off-by: kmova --- openebs/openebs-provisioner.go | 5 +++++ openebs/types/v1/types.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/openebs/openebs-provisioner.go b/openebs/openebs-provisioner.go index c262c72b9e5..4a80421b75a 100644 --- a/openebs/openebs-provisioner.go +++ b/openebs/openebs-provisioner.go @@ -111,6 +111,11 @@ func (p *openEBSProvisioner) Provision(options controller.VolumeOptions) (*v1.Pe volumeSpec.Metadata.Labels.PersistentVolumeClaim = options.PVC.ObjectMeta.Name volumeSpec.Metadata.Name = options.PVName + //Pass through labels from PVC to maya-apiserver + volumeSpec.Metadata.Labels.Application = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsApplication] + volumeSpec.Metadata.Labels.ReplicaTopoKeyDomain = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsREplicaTopKeyDomain] + volumeSpec.Metadata.Labels.ReplicaTopoKeyType = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsREplicaTopKeyType] + _, err := openebsVol.CreateVolume(volumeSpec) if err != nil { glog.Errorf("Error creating volume: %v", err) diff --git a/openebs/types/v1/types.go b/openebs/types/v1/types.go index 764b1c59d5a..43540e315a2 100644 --- a/openebs/types/v1/types.go +++ b/openebs/types/v1/types.go @@ -16,7 +16,13 @@ limitations under the License. package v1 -//VolumeSpec holds the config for creating a VSM +const ( + PVCLabelsApplication = "volumeprovisioner.mapi.openebs.io/application" + PVCLabelsREplicaTopKeyDomain = "volumeprovisioner.mapi.openebs.io/replica-topology-key-domain" + PVCLabelsREplicaTopKeyType = "volumeprovisioner.mapi.openebs.io/replica-topology-key-type" +) + +//VolumeSpec holds the config for creating a OpenEBS Volume type VolumeSpec struct { Kind string `yaml:"kind"` APIVersion string `yaml:"apiVersion"` @@ -27,6 +33,9 @@ type VolumeSpec struct { StorageClass string `yaml:"k8s.io/storage-class"` Namespace string `yaml:"k8s.io/namespace"` PersistentVolumeClaim string `yaml:"k8s.io/pvc"` + Application string `yaml:"volumeprovisioner.mapi.openebs.io/application,omitempty"` + ReplicaTopoKeyDomain string `yaml:"volumeprovisioner.mapi.openebs.io/replica-topology-key-domain,omitempty"` + ReplicaTopoKeyType string `yaml:"volumeprovisioner.mapi.openebs.io/replica-topology-key-type,omitempty"` } `yaml:"labels"` } `yaml:"metadata"` CloneIP string `yaml:"cloneIP"` From 4588d210ee82497e0f9573302b51a4012df4f8bb Mon Sep 17 00:00:00 2001 From: kmova Date: Fri, 29 Jun 2018 08:12:31 +0000 Subject: [PATCH 2/2] Fix the spelling as per review Signed-off-by: kmova --- openebs/openebs-provisioner.go | 4 ++-- openebs/types/v1/types.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openebs/openebs-provisioner.go b/openebs/openebs-provisioner.go index 4a80421b75a..296ea52612d 100644 --- a/openebs/openebs-provisioner.go +++ b/openebs/openebs-provisioner.go @@ -113,8 +113,8 @@ func (p *openEBSProvisioner) Provision(options controller.VolumeOptions) (*v1.Pe //Pass through labels from PVC to maya-apiserver volumeSpec.Metadata.Labels.Application = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsApplication] - volumeSpec.Metadata.Labels.ReplicaTopoKeyDomain = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsREplicaTopKeyDomain] - volumeSpec.Metadata.Labels.ReplicaTopoKeyType = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsREplicaTopKeyType] + volumeSpec.Metadata.Labels.ReplicaTopoKeyDomain = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsReplicaTopKeyDomain] + volumeSpec.Metadata.Labels.ReplicaTopoKeyType = options.PVC.ObjectMeta.GetLabels()[mayav1.PVCLabelsReplicaTopKeyType] _, err := openebsVol.CreateVolume(volumeSpec) if err != nil { diff --git a/openebs/types/v1/types.go b/openebs/types/v1/types.go index 43540e315a2..8da4d623a9f 100644 --- a/openebs/types/v1/types.go +++ b/openebs/types/v1/types.go @@ -18,8 +18,8 @@ package v1 const ( PVCLabelsApplication = "volumeprovisioner.mapi.openebs.io/application" - PVCLabelsREplicaTopKeyDomain = "volumeprovisioner.mapi.openebs.io/replica-topology-key-domain" - PVCLabelsREplicaTopKeyType = "volumeprovisioner.mapi.openebs.io/replica-topology-key-type" + PVCLabelsReplicaTopKeyDomain = "volumeprovisioner.mapi.openebs.io/replica-topology-key-domain" + PVCLabelsReplicaTopKeyType = "volumeprovisioner.mapi.openebs.io/replica-topology-key-type" ) //VolumeSpec holds the config for creating a OpenEBS Volume