-
Notifications
You must be signed in to change notification settings - Fork 399
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
Set organization home dashboard #1301
Conversation
Signed-off-by: João Henri <[email protected]>
Signed-off-by: João Henri <[email protected]>
Signed-off-by: João Henri <[email protected]> wip: Use PUT endpoint
5c92e2e
to
8e66ce0
Compare
return err | ||
} | ||
|
||
p, err := grafanaClient.OrgPreferences() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a small bug in the grafana-api-go-client that makes us unable to use the PATCH endpoint, having to GET first and then PUT. I solved it in this PR, so I'm waiting for a new release to change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaehnri thanks for the PR!
Though, if I understand your code correctly, you're suggesting to update the org home dashboard upon reconciling any of the dashboards. That means, for 100 dashboards, the org settings will be updated 100 times.
Plus, Grafana API refuses to update the setting when you pass an uid
that does not exist yet. Say, we have 100 dashboards and the operator just started. Then it can potentially run into two issues:
- If we look at the queue, and the target dashboard is on the 100th place there, the reconciliations for the first 99 dashboards will fail;
- If you specify a non-existent
uid
, reconciliation will never succeed for any of the dashboards.
Unfortunately, this setting is tricky, we need to come up with something more nuanced.
Hi, @weisdd! Thanks for the review.
That way, if a nonexistent dashboard is chosen, the condition above never holds true and simply no home dashboard will ever be set up. Also, we only send the PATCH after the dashboard creation, so we will never send a request with a UID that Grafana does not know (the Also, it only makes the API call for the home dashboard after the check above, so there's no chance we will update the settings 100 times. |
@jaehnri Alright, it should work then. We'll look at the PR deeper in the coming days. Thanks for the clarification! |
For me, it feels a bit strange to have this config in the grafana CRD but have the Dashboard reconciler doing the work. It especially gets strange if we want to start setting org timezone or grafana extend the So in the spirit of being practical, LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NissesSenap I'd agree, it's a good enough solution for now. If we ever come up with a better idea, we can reimplement the solution then.
As a side note, I've added a tiny fix - updated bundle manifest (make bundle
).
By the way, when a dashboard is deleted, the setting gets reset by Grafana itself, which nice :) |
Thanks for the review! I agree the solution isn't as elegant as one would hope but it does work. |
Closes #896