fix(GrafanaDatasource): don't treat missing datasource as an error when deleting datasource #1879
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.
A similar PR as for the issue regarding
grafanafolder
controller #1516 but for thegrafanadatasource
controller.This solves two problems
Datasource removed from Grafana instance but not yet from Grafana CRD
Looks like when we retrieve the ID or try to the delete the resource and we receive an error we only return the exception on
NotFound
. While we should proceed onNotFound
(to delete the resource from the Grafana CRD) and return on any other exception.This will happen when a datasource is for example manually deleted using the the UI. And will loop forever.
Reconciler error
Datasource removed from Grafana CRD when client throws an error
The other side of this is that when an error occurs that is anything but
NotFound
:if errors.As(err, ¬Found) > False > remove datasource
the datasource is removed from the Grafana CRD status anyway.Code
Bug
Feature