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 5 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
32 changes: 24 additions & 8 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 All @@ -77,12 +76,7 @@ class UpdateSecrets(Patch):

def __call__(self, obj):
"""Update the secret volume spec in daemonsets and deployments."""
if not any(
[
(obj.kind == "DaemonSet" and obj.metadata.name == "csi-cinder-nodeplugin"),
(obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"),
]
):
if not (obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops... i didn't do you well if i suggested this line change. This shouldn't be changed. It was totally incorrect before

Suggested change
if not (obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"):
if not any(
[
(obj.kind == "DaemonSet" and obj.metadata.name == "csi-cinder-nodeplugin"),
(obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"),
]
):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gosh, my mistake

return

for volume in obj.spec.template.spec.volumes:
Expand All @@ -105,6 +99,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 +137,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):
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 any(
[
(obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"),
]
):
VariableDeclared marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead this one only appiles to the controller plugins

Suggested change
if not any(
[
(obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"),
]
):
if not (obj.kind == "Deployment" and obj.metadata.name == "csi-cinder-controllerplugin"):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

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)
Loading