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

New grafanafolder#spec.uid property for stable UIDs #1636

Open
Baarsgaard opened this issue Aug 12, 2024 · 4 comments
Open

New grafanafolder#spec.uid property for stable UIDs #1636

Baarsgaard opened this issue Aug 12, 2024 · 4 comments
Labels
enhancement New feature or request triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@Baarsgaard
Copy link
Contributor

Baarsgaard commented Aug 12, 2024

Defining a disaster-recovery process when recreating the Grafana Operator resources from scratch.

If I lose my cluster, ETCD state, or I mess up in a CD pipeline and any grafanafolder cr is deleted.
Recreating it results in an entirely new metadata.uid.

Currently, the only way to recover from this is through manually/programmatically:

  1. Connect to every managed instance with the deleted folder
  2. Delete all provisioned Alertrules and Dashboards
  3. Delete the existing folder with the old UID
  4. Have Grafana-Operator recreate the Folder, Alertrules, and Dashboards

Describe the solution you'd like
UID property on grafanafolder resource to ensure it's always the same for a specific folder name.

Describe alternatives you've considered

  • Using folderUID on Alertrules/Dashboards
    This could work, except when onboarding new Grafana instances the folder does not exist and I cannot create the dashboards
  • Using folder
    The folder will always have a different UID for each Grafana Instance. This could work, both when provisioning and Deleting.
    It does however mean I cannot use the folderRef and folderUID properties on Alertrules and Dashboards and the grafanafolder crd.
  • I have tried "Tricking" the operator by applying a GrafanaFolder with the metadata.uid already specified, but it's overwritten on first apply.
@Baarsgaard Baarsgaard added enhancement New feature or request needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 12, 2024
@Baarsgaard
Copy link
Contributor Author

Baarsgaard commented Aug 15, 2024

I have since found out, the same issue is present on GrafanaContactPoint and GrafanaNotificationPolicy which also does not allow specifying UIDs

@pb82
Copy link
Collaborator

pb82 commented Aug 19, 2024

Allowing custom UIDs on folders can become complicated (more complicated than other resources), because: if you change the UID on an already existing folder, what do you do with the original one and all the dashboards it contains? You'd have to write special logic to handle those cases (and agree on a policy).

@Baarsgaard
Copy link
Contributor Author

Baarsgaard commented Aug 19, 2024

Could that be handled/enforced through an immutability clause requiring a recreate rather than an edit of the Grafanafolder resource?
You already have that on the metadata.uid and instanceSelector.matchLabels in the CRDs I believe.

x-kubernetes-validations:
  - message: Value is immutable
    rule: self == oldSelf

That way, changing the UID is officially not supported, but it's possible to define an ID on creation?
This would also be compatible with #1626 which fixes blocking folder deletes when referenced without extra logic.

@theSuess theSuess added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 26, 2024
@theSuess
Copy link
Member

@aboulay-numspot will try to implement this with immutable UIDs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

3 participants