diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b0d692..fab4f83 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,7 @@ on: [pull_request] jobs: call-inclusive-naming-check: name: Inclusive Naming - uses: canonical-web-and-design/Inclusive-naming/.github/workflows/woke.yaml@main + uses: canonical/inclusive-naming/.github/workflows/woke.yaml@main with: fail-on-error: "true" diff --git a/config.yaml b/config.yaml index 2aceeb2..753708d 100644 --- a/config.yaml +++ b/config.yaml @@ -42,4 +42,16 @@ options: type: boolean default: True description: | - Whether to enable the Cinder CSI topology awareness \ No newline at end of file + Whether to enable the Cinder CSI topology awareness + + reclaim-policy: + type: string + default: "Delete" + description: | + https://kubernetes.io/docs/concepts/storage/storage-classes/#reclaim-policy + + The reclaim policy for the PVCs created by the CSI driver. This is passed + through to the parameters.reclaimPolicy field of the csi-cinder-default + StorageClass. + + Potential values are "Delete" or "Retain" \ No newline at end of file diff --git a/src/config.py b/src/config.py index 7829ebb..7e25fa1 100644 --- a/src/config.py +++ b/src/config.py @@ -27,4 +27,6 @@ def available_data(self): def evaluate(self) -> Optional[str]: """Determine if configuration is valid.""" + if self.config["reclaim-policy"].title() not in ["Delete", "Retain"]: + return "reclaim-policy should be either 'Delete' or 'Retain'" return None diff --git a/src/storage_manifests.py b/src/storage_manifests.py index 5a6a724..3853a7e 100644 --- a/src/storage_manifests.py +++ b/src/storage_manifests.py @@ -56,13 +56,15 @@ def __call__(self) -> Optional[AnyResource]: """Craft the storage class object.""" storage_name = STORAGE_CLASS_NAME.format(type=self.type) log.info(f"Creating storage class {storage_name}") + reclaim_policy: str = self.manifests.config.get("reclaim-policy") or "Delete" + sc = from_dict( dict( apiVersion="storage.k8s.io/v1", kind="StorageClass", metadata=dict(name=storage_name), provisioner="cinder.csi.openstack.org", - reclaimPolicy="Delete", + reclaimPolicy=reclaim_policy.title(), volumeBindingMode="WaitForFirstConsumer", ) )