Skip to content

Commit

Permalink
Fix availability zones and topology configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
VariableDeclared committed Mar 27, 2024
1 parent 2d00c38 commit 7fd24aa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
8 changes: 3 additions & 5 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ bases:
- name: ubuntu
channel: "20.04"
architectures:
- amd64
- arm64
- "amd64"
- name: ubuntu
channel: "22.04"
architectures:
- amd64
- arm64
architectures:
- "amd64"
parts:
charm:
build-packages:
Expand Down
6 changes: 6 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ options:
description: |
Availability zone to use with Cinder CSI. This is passed through to the
parameters.availability field of the csi-cinder-default StorageClass.
topology:
type: boolean
default: True
description: |
Whether to enable the Cinder CSI topology awareness
28 changes: 25 additions & 3 deletions src/storage_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def __call__(self) -> Optional[AnyResource]:
metadata=dict(name=storage_name),
provisioner="cinder.csi.openstack.org",
reclaimPolicy="Delete",
volumeBindingMode="WaitForFirstConsumer",
volumeBindingMode="WaitForFirstConsumer"
)
)

if az := self.manifests.config.get("availability-zone"):
sc.parameters.availability = az
sc.parameters = dict(availability=az)
return sc


Expand Down Expand Up @@ -105,6 +105,7 @@ def __init__(self, charm, charm_config, kube_control, integrator):
ConfigRegistry(self),
CreateStorageClass(self, "default"), # creates csi-cinder-default
UpdateSecrets(self), # update secrets
UpdateControllerPlugin,
],
)
self.integrator = integrator
Expand Down Expand Up @@ -142,3 +143,24 @@ def evaluate(self) -> Optional[str]:
if not self.config.get(prop):
return f"Storage manifests waiting for definition of {prop}"
return None

class UpdateControllerPlugin(Patch):
"""Update the controller args in Deployments."""

def __call__(self, obj):
"""Update the controller args in Deployments."""
if not any(
[
(obj.kind == "DaemonSet" and obj.metadata.name == "csi-cinder-nodeplugin"),
(obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"),
]
):
return

for container in obj.spec.template.spec.containers:
if container.name == "csi-provisioner":
for i, val in enumerate(container.args):
if "feature-gates" in val.lower():
container.args[i] = f"feature-gates=Topology={self.manifests.config.get('topology')}"
log.info(f"Disabling cinder topology awareness")

0 comments on commit 7fd24aa

Please sign in to comment.