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: purge any cephfs storage classes installed by ops.manifest #38

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

addyess
Copy link
Member

@addyess addyess commented Feb 11, 2025

fix: Purge cephfs storage class purging by purging only those SCs labelled by this app and manifest

Addresses LP#2098004

Depends on

@addyess addyess force-pushed the bug/lp2098004/purge-cephfs-sc-without-knowning-names branch from de4acaf to dbf9ac3 Compare February 11, 2025 17:10
Comment on lines +177 to +181
if cast(SafeManifest, self.manifests).purgeable:
# If we are purging, we may not be able to create any storage classes
# Just return a fake storage class to satisfy delete_manifests method
# which will look up all storage classes installed by this app/manifest
return [StorageClass.from_dict(dict(metadata={}, provisioner=self.PROVISIONER))]
Copy link
Member

Choose a reason for hiding this comment

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

There's something I don't understand in this dunder method. Why do we need to create an empty sc when we are purging? Could there be any leftover sc, or is this just an edge case?

Copy link
Member Author

@addyess addyess Feb 11, 2025

Choose a reason for hiding this comment

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

Manifest objects can support Manipulations. These are enacted by calling the Manipulation.

The types of manipulations are defined in the project

  • Subtraction
  • Patch
  • Addition

In this case. The CephStorageClass manipulation is an Addition. It is a set of objects added to the existing static manifests in the upstream yaml files. ops.manifest will call this manipulation to create the lightkube resource definition for the storage class.

Normally, for INSTALLING resources, this is straight forward to create these additions. ops.manifest knows the resources it should add. But in the purging situation, it's a bit different. We want to make sure that ops.manifest can delete all the objects this manifest may have added.

What's worse, is we don't REALLY know the name of the storage classes when we're purging. The state information necessary to generate the list of storage class names is gone (it was the cephfs filesystem listings).

But ops.manifest would have labelled each kubernetes resource with some metadata labels to indicate which manifest placed it into the cluster. In this case, if any storage class is created, it will have two labels associated with it:

- juju.io/application: ceph-csi-app-name # from the running application
- juju.io/manifest: cephfs  # from this module

What this __call__ is returning is a single list of StorageClasses with no names.

when ops.manifest builds its list of resources, it will query the cluster looking for all the StorageClasses with these matching labels and then delete those resources if they were found

@addyess addyess merged commit dba68cb into main Feb 11, 2025
7 checks passed
@addyess addyess deleted the bug/lp2098004/purge-cephfs-sc-without-knowning-names branch February 11, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants