Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix availability zones and topology configuration #5

Merged
merged 9 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 19 additions & 2 deletions src/storage_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def __call__(self) -> Optional[AnyResource]:
volumeBindingMode="WaitForFirstConsumer",
)
)

if az := self.manifests.config.get("availability-zone"):
sc.parameters.availability = az
sc.parameters = dict(availability=az)
addyess marked this conversation as resolved.
Show resolved Hide resolved
return sc


Expand Down Expand Up @@ -105,6 +104,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),
],
)
self.integrator = integrator
Expand Down Expand Up @@ -142,3 +142,20 @@ 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):
VariableDeclared marked this conversation as resolved.
Show resolved Hide resolved
"""Update the controller args in Deployments."""

def __call__(self, obj):
"""Update the controller args in Deployments."""
if not (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():
topology = str(self.manifests.config.get("topology")).lower()
container.args[i] = f"feature-gates=Topology={topology}"
log.info("Configuring cinder topology awareness=%s", topology)
1 change: 1 addition & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def test_waits_for_kube_control(mock_create_kubeconfig, harness, caplog):
"Creating storage class csi-cinder-default",
"Setting secret for DaemonSet/csi-cinder-nodeplugin",
"Setting secret for Deployment/csi-cinder-controllerplugin",
"Configuring cinder topology awareness=true",
}

caplog.clear()
Loading