Skip to content

Commit

Permalink
don't treat missing datasource as an error when deleting datasource (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lexhuismans authored Feb 28, 2025
1 parent 10b863e commit 9affc62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions controllers/datasource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func (r *GrafanaDatasourceReconciler) syncDatasources(ctx context.Context) (ctrl
instanceDatasource, err := grafanaClient.Datasources.GetDataSourceByUID(uid)
if err != nil {
var notFound *datasources.GetDataSourceByUIDNotFound
if errors.As(err, &notFound) {
if !errors.As(err, &notFound) {
return ctrl.Result{}, err
}
log.Info("datasource no longer exists", "namespace", namespace, "name", name)
} else {
_, err = grafanaClient.Datasources.DeleteDataSourceByUID(instanceDatasource.Payload.UID) //nolint
if err != nil {
var notFound *datasources.DeleteDataSourceByUIDNotFound
if errors.As(err, &notFound) {
if !errors.As(err, &notFound) {
return ctrl.Result{}, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/grafanafolder_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *GrafanaFolderReconciler) syncFolders(ctx context.Context) (ctrl.Result,
for _, folder := range existingFolders {
// avoid bombarding the grafana instance with a large number of requests at once, limit
// the sync to a certain number of folders per cycle. This means that it will take longer to sync
// a large number of deleted dashboard crs, but that should be an edge case.
// a large number of deleted folders crs, but that should be an edge case.
if foldersSynced >= syncBatchSize {
return ctrl.Result{Requeue: true}, nil
}
Expand Down

0 comments on commit 9affc62

Please sign in to comment.