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

feat(dashboard): nullify hardcoded id #1111

Merged
merged 1 commit into from
Jun 18, 2023
Merged

Conversation

weisdd
Copy link
Collaborator

@weisdd weisdd commented Jun 18, 2023

When id is hardcoded in a GrafanaDashboard, the operator is likely to fail to create the dashboard in a Grafana instance.
The PR makes sure id is nullified before dashboard model is passed to Grafana client.

(Strictly speaking, id should never be defined by a user in the first place, so it's more around improving UX.)

More details

Basically, when id is set, Grafana tries to update a dashboard by the id, not uid. And, expectedly, that can cause various issues, e.g. if the id is not known to Grafana, Grafana responds with 404.

Example of a failing CR

apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
  name: grafanadashboard-sample
spec:
  resyncPeriod: 30s
  instanceSelector:
    matchLabels:
      dashboards: "grafana"
  json: >
    {
      "id": 146,
      "title": "Simple Dashboard",
      "tags": [],
      "style": "dark",
      "timezone": "browser",
      "editable": true,
      "hideControls": false,
      "graphTooltip": 1,
      "panels": [],
      "time": {
        "from": "now-6h",
        "to": "now"
      },
      "timepicker": {
        "time_options": [],
        "refresh_intervals": []
      },
      "templating": {
        "list": []
      },
      "annotations": {
        "list": []
      },
      "refresh": "5s",
      "schemaVersion": 17,
      "version": 0,
      "links": []
    }

Fixes: #1108

@weisdd weisdd added the enhancement New feature or request label Jun 18, 2023
@weisdd weisdd self-assigned this Jun 18, 2023
@weisdd weisdd changed the title feat: nullify hardcoded id in dashboards feat(dashboard): nullify hardcoded id Jun 18, 2023
Copy link
Collaborator

@NissesSenap NissesSenap left a comment

Choose a reason for hiding this comment

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

Sounds very reasonable to me. LGTM

@weisdd weisdd merged commit ddb3a9f into master Jun 18, 2023
@weisdd weisdd deleted the feat/nullify-dashboard-id branch June 18, 2023 11:46
@owenhaynes
Copy link

Will there be a patch release soon for this fix? Currently looking to migrate form v4 -> v5 and this is a little bit of regression. I know v5 is a major release. Its just a shame Grafana does not by default exclude this id when exporting dashboards.

@weisdd
Copy link
Collaborator Author

weisdd commented Jun 26, 2023

@owenhaynes it's now part of v5.0.2 that got released today :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GrafanaDashboard] operator fails to create a dashboard with hardcoded id
3 participants