Skip to content

Commit 61d2675

Browse files
committed
feat: enable manila volumesnapshotclass if share_network_id is specified
Signed-off-by: Tadas Sutkaitis <[email protected]>
1 parent dd7af9f commit 61d2675

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

magnum_cluster_api/resources.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ def get_object(self) -> dict:
364364
},
365365
}
366366

367-
# Add snapshot controller CSI chart if either Cinder CSI or Manila CSI is enabled
367+
# Add snapshot controller CSI chart if either Cinder CSI or Manila CSI is enabled.
368368
if cinder.is_enabled(self.cluster) or manila.is_enabled(self.cluster):
369369

370-
# Build volume snapshot classes based on enabled CSI drivers
370+
# Build volume snapshot classes based on enabled CSI drivers.
371371
volume_snapshot_classes = []
372372

373-
# Add Cinder CSI volume snapshot class if enabled
373+
# Add Cinder CSI volume snapshot class if enabled.
374374
if cinder.is_enabled(self.cluster):
375375
volume_snapshot_classes.append(
376376
{
@@ -383,22 +383,26 @@ def get_object(self) -> dict:
383383
}
384384
)
385385

386-
# Add Manila CSI volume snapshot class if enabled
386+
# Add Manila CSI volume snapshot class if enabled and share_network_id is specified.
387387
if manila.is_enabled(self.cluster):
388-
volume_snapshot_classes.append(
389-
{
390-
"name": "share-snapshot",
391-
"annotations": {
392-
"snapshot.storage.kubernetes.io/is-default-class": "true"
393-
},
394-
"driver": "nfs.manila.csi.openstack.org",
395-
"deletionPolicy": "Delete",
396-
"parameters": {
397-
"csi.storage.k8s.io/snapshotter-secret-name": "csi-manila-secrets",
398-
"csi.storage.k8s.io/snapshotter-secret-namespace": "kube-system",
399-
},
400-
}
388+
share_network_id = self.cluster.labels.get(
389+
"manila_csi_share_network_id"
401390
)
391+
if share_network_id:
392+
volume_snapshot_classes.append(
393+
{
394+
"name": "share-snapshot",
395+
"annotations": {
396+
"snapshot.storage.kubernetes.io/is-default-class": "true"
397+
},
398+
"driver": "nfs.manila.csi.openstack.org",
399+
"deletionPolicy": "Delete",
400+
"parameters": {
401+
"csi.storage.k8s.io/snapshotter-secret-name": "csi-manila-secrets",
402+
"csi.storage.k8s.io/snapshotter-secret-namespace": "kube-system",
403+
},
404+
}
405+
)
402406

403407
controller_values = {
404408
"fullnameOverride": "snapshot-controller",

0 commit comments

Comments
 (0)