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

Automatically overwrite dashboard UIDs with a prescribed naming pattern, on the provider side #363

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

sed-i
Copy link
Contributor

@sed-i sed-i commented Dec 6, 2024

Issue

Solution

Use shake_256 to generate alt-uid, and always use it, overwriting any pre-existing uid.

In tandem with:

Context

Afaict, the only user of the .add_dashboard method is https://github.com/canonical/cos-registration-server-k8s-operator/blob/6e156f0b1367f7cc6ce12d89f6a367bf491fea7f/src/charm.py#L240.

Testing Instructions

First, prepare the charms locally:

  1. Copy the grafana_dashboard lib from this PR into grafana-agent-operator from Autogenerate dashboard_alt_uid on the provider side grafana-agent-operator#224.
  2. Copy cos-agent lib from Autogenerate dashboard_alt_uid on the provider side grafana-agent-operator#224 into zookeeper.
  3. In zookeeper, update deps using the following commands. Then remove all the --hash from requirements.txt:
poetry update
poetry lock
poetry install
poetry export -f requirements.txt --output requirements.tx
  1. Pack and deploy all charms as follows:
graph LR
subgraph lxd
zookeeper --- grafana-agent
zookeeper2 --- grafana-agent
end
subgraph microk8s
grafana-agent --- grafana
end
Loading
bundle: kubernetes
applications:
  graf:
    charm: ./grafana-k8s_ubuntu-20.04-amd64.charm
    scale: 1
    trust: true
--- # overlay.yaml
applications:
  graf:
    offers:
      graf:
        endpoints:
        - grafana-dashboard
        acl:
          admin: admin
default-base: [email protected]/stable
saas:
  graf:
    url: microk8s:admin/graf.graf
applications:
  ga2:
    charm: ./grafana-agent_ubuntu-22.04-amd64.charm
  zk:
    charm: ./zookeeper_ubuntu-22.04-amd64.charm
    num_units: 2
  zk2:
    charm: ./zookeeper_ubuntu-22.04-amd64.charm
    num_units: 2
relations:
- - ga2:cos-agent
  - zk:cos-agent
- - ga2:cos-agent
  - zk2:cos-agent
- - ga2:grafana-dashboards-provider
  - graf:grafana-dashboard

Upgrade Notes

To enable automatic uid collision prevention for the dashboards in your charm:

  1. If cos-lib (cosl) is pinned in your charm, bump it to 0.0.50 or higher.
  2. Fetch-lib cos-agent. You should use 0.13 or higher.
  3. Refresh your charm.
  4. Refresh grafana-agent to revision 369+.

@sed-i
Copy link
Contributor Author

sed-i commented Dec 6, 2024

@jdkandersson
Copy link

I'll delegate to @cbartz who has the best understanding of the issue in our team, thank you for preparing the PR!

@sed-i sed-i force-pushed the feature/uid-collision branch from 6acd42e to 64ddc56 Compare December 20, 2024 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants