Skip to content

Commit 8e29018

Browse files
committed
[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 kubernetes-csi/external-provisioner#399 Signed-off-by: Fabian Ruff <[email protected]>
1 parent 7361943 commit 8e29018

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/csi/cinder/controllerserver.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
103103

104104
// Volume Create
105105
properties := map[string]string{"cinder.csi.openstack.org/cluster": cs.Driver.cluster}
106+
//Tag volume with metadata if present: https://github.com/kubernetes-csi/external-provisioner/pull/399
107+
for k, v := range req.Parameters {
108+
for _, mKey := range []string{"csi.storage.k8s.io/pvc/name", "csi.storage.k8s.io/pvc/namespace", "csi.storage.k8s.io/pv/name"} {
109+
if k == mKey {
110+
properties[k] = v
111+
}
112+
}
113+
}
106114
content := req.GetVolumeContentSource()
107115
var snapshotID string
108116
var sourcevolID string

0 commit comments

Comments
 (0)