From 8e2901859ff8b11bccf9232c2a368fc90e7467d1 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Thu, 22 Apr 2021 14:22:35 +0200 Subject: [PATCH] [cinder-csi-plugin] Tag volume with optional metadata The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags. See https://github.com/kubernetes-csi/external-provisioner/pull/399 Signed-off-by: Fabian Ruff --- pkg/csi/cinder/controllerserver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go index 1c8e7dbd5f..fba10a12ed 100644 --- a/pkg/csi/cinder/controllerserver.go +++ b/pkg/csi/cinder/controllerserver.go @@ -103,6 +103,14 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // Volume Create properties := map[string]string{"cinder.csi.openstack.org/cluster": cs.Driver.cluster} + //Tag volume with metadata if present: https://github.com/kubernetes-csi/external-provisioner/pull/399 + for k, v := range req.Parameters { + for _, mKey := range []string{"csi.storage.k8s.io/pvc/name", "csi.storage.k8s.io/pvc/namespace", "csi.storage.k8s.io/pv/name"} { + if k == mKey { + properties[k] = v + } + } + } content := req.GetVolumeContentSource() var snapshotID string var sourcevolID string