fix: recreate a notification channel if it doesn't exist in grafana #813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, a notification channel in grafana gets recreated by the operator only in two cases:
The PR makes operator always check whether a notification channel exist in grafana. If not, it gets submitted again.
Also, it fixes a log message
delete result was %v
. Previously, the code would try to substitute%v
with a UID which would always be empty. Now, it usesMessage
from grafana response.The logic is somewhat similar to what we have in the grafana dashboard controller and pipeline.
Relevant issues/tickets
Fixes: #811
Type of change
Checklist
Verification steps
Preparation
Like described in the issue #811, deploy grafana with unified alerting disabled:
NOTE: Unified alerting seems to be introduced in grafana 8.x, so should be no need to enable it on earlier versions. I tested on
9.0.2
since the latest images are built with M1 support.Deploy a notification channel CR like in our deploy example:
Test cases
Create CR
=> created
Update CR
=> updated
Delete the notification channel from grafana interface
=> recreated
Restart operator
=> updated with the same spec
Delete CR
=> deleted