-
Notifications
You must be signed in to change notification settings - Fork 435
Add Uid to the error log when reconciling dashboards #2143 #2173
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
Open
RaviTejaNalluri
wants to merge
3
commits into
grafana:master
Choose a base branch
from
RaviTejaNalluri:Adding-UID
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+8
−6
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,20 +174,20 @@ func (r *GrafanaDashboardReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
err = ReconcilePlugins(ctx, r.Client, r.Scheme, &grafana, cr.Spec.Plugins, fmt.Sprintf("%v-dashboard", cr.Name)) | ||
if err != nil { | ||
pluginErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = err.Error() | ||
log.Error(err, "error reconciling plugins", "dashboard", cr.Name, "grafana", grafana.Name) | ||
log.Error(err, "error reconciling plugins", "dashboard", cr.Name, "grafana", grafana.Name, "uid", uid) | ||
} | ||
} | ||
|
||
// then import the dashboard into the matching grafana instances | ||
err = r.onDashboardCreated(ctx, &grafana, cr, dashboardModel, hash, folderUID) | ||
if err != nil { | ||
applyErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = err.Error() | ||
applyErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = fmt.Sprintf("uid=%s: %s", uid, err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would revert this addition as we print all the errors at the end of the reconciliation. |
||
} | ||
|
||
if grafana.Spec.Preferences != nil && uid == grafana.Spec.Preferences.HomeDashboardUID { | ||
err = r.UpdateHomeDashboard(ctx, grafana, uid, cr) | ||
if err != nil { | ||
applyHomeErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = err.Error() | ||
applyHomeErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = fmt.Sprintf("uid=%s: %s", uid, err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this 🙂 |
||
} | ||
} | ||
} | ||
|
@@ -208,7 +208,7 @@ func (r *GrafanaDashboardReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
meta.SetStatusCondition(&cr.Status.Conditions, condition) | ||
|
||
if len(allApplyErrors) > 0 { | ||
return ctrl.Result{}, fmt.Errorf("failed to apply to all instances: %v", allApplyErrors) | ||
return ctrl.Result{}, fmt.Errorf("uid=%s: failed to apply to all instances: %v", uid, allApplyErrors) | ||
} | ||
|
||
cr.Status.Hash = hash | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
It is a mistake that we log here as the error is added to the
pluginErrors
map and printed later, we should instead remove this to not log the same error twice 😅