Skip to content

chore(controllers): normalize logging#2382

Merged
Baarsgaard merged 23 commits intomasterfrom
chore_controllers_normalize_logging
Jan 27, 2026
Merged

chore(controllers): normalize logging#2382
Baarsgaard merged 23 commits intomasterfrom
chore_controllers_normalize_logging

Conversation

@Baarsgaard
Copy link
Copy Markdown
Collaborator

@Baarsgaard Baarsgaard commented Dec 15, 2025

Refactors all controllers to follow the pattern of explicitly logging using the logger when returning an error.

This means error logs now include variables attached to the current logger, like UIDs, names, etc.
Log messages are now significantly more static resulting in better compatibility with solutions like Elastic/OpenSearch

@github-actions github-actions Bot added the chore label Dec 15, 2025
@github-actions
Copy link
Copy Markdown

This PR hasn't been updated for a while, marking as stale

@github-actions github-actions Bot added the stale label Jan 15, 2026
@Baarsgaard Baarsgaard removed the stale label Jan 19, 2026
@Baarsgaard Baarsgaard force-pushed the chore_controllers_normalize_logging branch from 3711dbc to 96a326c Compare January 19, 2026 20:21
@Baarsgaard Baarsgaard marked this pull request as ready for review January 19, 2026 22:48
Comment on lines +56 to +65
// Log messages
ErrMsgNoMatchingInstances = "instanceSelector found no matching Grafana instances"
ErrMsgGettingCR = "failed to get CR from API Server"
ErrMsgGettingInstances = "failed to get Grafana instances"
ErrMsgResolvingFolderUID = "fetching GrafanaFolder to resolve uid"
ErrMsgRunningFinalizer = "failed to finalize CR"
ErrMsgRemoveFinalizer = "failed to remove finalizer"
ErrMsgApplyErrors = "failed to sync CR to all Grafana instances"

DbgMsgFoundMatchingInstances = "found matching Grafana instances"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use this chance to align our error messages, but I don't know if there's any preferences?

Comment thread controllers/controller_shared.go Outdated
@Baarsgaard Baarsgaard requested a review from theSuess January 20, 2026 19:29
@Baarsgaard Baarsgaard force-pushed the chore_controllers_normalize_logging branch from 7386059 to 0acfe47 Compare January 24, 2026 15:34
@theSuess
Copy link
Copy Markdown
Collaborator

Pushed a commit to go from ErrMsg to LogMsg as discussed in the weekly

Copy link
Copy Markdown
Collaborator Author

@Baarsgaard Baarsgaard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theSuess I would approve your changes, but Github won't let me as I opened the PR :D
LGTM

@Baarsgaard Baarsgaard added this pull request to the merge queue Jan 27, 2026
Merged via the queue into master with commit 3ac4242 Jan 27, 2026
17 checks passed
@Baarsgaard Baarsgaard deleted the chore_controllers_normalize_logging branch January 27, 2026 12:54
@weisdd weisdd changed the title chore(Controllers): Normalize logging chore(controllers): normalize logging Feb 19, 2026
alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Feb 24, 2026
…4201)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [grafana/grafana-operator](https://github.com/grafana/grafana-operator) | minor | `v5.21.4` → `v5.22.0` |

---

### Release Notes

<details>
<summary>grafana/grafana-operator (grafana/grafana-operator)</summary>

### [`v5.22.0`](https://github.com/grafana/grafana-operator/releases/tag/v5.22.0)

[Compare Source](grafana/grafana-operator@v5.21.4...v5.22.0)

<!-- Release notes generated using configuration in .github/release.yml at master -->

We're happy to announce version 5.22.0 of the Grafana Operator!

This release contains a bunch of new and exciting features like:

- The brand new [`GrafanaManifest`](https://grafana.github.io/grafana-operator/docs/examples/manifests/) resource
  - This allows you to manage resources previously not supported by the operator but available through the new Kuberentes-style Grafana APIs (e.g Playlists, ShortURLs) as well as resources introduced by plugins (e.g. Frontend O11y configuration in Grafana Cloud).
- Dynamic resource patching (currently only available to `GrafanaManifest` resources)
  - Patch resources with arbitrary `jq` scripts before submitting them to the Grafana API!
- Alert rule groups have been updated to support more fields exposed by the Grafana API
- Service accounts no longer require a name and will default to `metadata.name`

#### Upgrade instructions

##### Using Helm

```sh

# Upgrade the operator image & deployment
helm upgrade -i grafana-operator oci://ghcr.io/grafana/helm-charts/grafana-operator --version 5.22.0

# Upgrading CRDs
kubectl apply --server-side --force-conflicts -f https://github.com/grafana/grafana-operator/releases/download/v5.22.0/crds.yaml
```

##### Using kubectl

```sh

# Namespace Scope
kubectl replace -f https://github.com/grafana/grafana-operator/releases/download/v5.22.0/kustomize-namespace_scoped.yaml

# Cluster Scope
kubectl replace -f https://github.com/grafana/grafana-operator/releases/download/v5.22.0/kustomize-cluster_scoped.yaml
```

##### Using kustomize

```sh
flux pull artifact oci://ghcr.io/grafana/kustomize/grafana-operator:v5.22.0 --output ./grafana-operator/
```

##### Using OLM

Releases are published to [operatorhub.io](https://operatorhub.io/operator/grafana-operator) as well as the OpenShift Operator Catalog. Depending on the installation, existing installations will either upgrade automatically or require approval from an administrator.

#### What's Changed

##### Changes that might need your attention

- chore(Helm): simplify helm chart by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2463](grafana/grafana-operator#2463)
  - We changed the default fallback for the cache strategy to `safe` instead of `off`. If you haven't explicitly set `enforceCacheLabels` to null, this does not affect you.

##### Features

- feat(controllers): add new GrafanaManifest resource by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2448](grafana/grafana-operator#2448)
- feat(GrafanaAlertRuleGroup): add support for targetDatasourceUid in recording rules by [@&#8203;RobertClarke64](https://github.com/RobertClarke64) in [#&#8203;2478](grafana/grafana-operator#2478)
- feat(GrafanaAlertRuleGroup): add support for `active_time_intervals` in `notificationSettings` by [@&#8203;heliapb](https://github.com/heliapb) in [#&#8203;2479](grafana/grafana-operator#2479)
- feat(GrafanaManifest): add support for dynamic resource patching by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2470](grafana/grafana-operator#2470)
- feat(GrafanaServiceAccount): Make `.spec.name` optional by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2524](grafana/grafana-operator#2524)

##### Fixes

- fix(GrafanaDashboard): update Grafana status even when remote state matches by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2440](grafana/grafana-operator#2440)
- fix(AlertRuleGroup): skip reconciliation when there's no drift in remote state by [@&#8203;heliapb](https://github.com/heliapb) in [#&#8203;2439](grafana/grafana-operator#2439)
- fix(GrafanaAlertRuleGroup): allow deprecated fields `dashboardUid` and `panelId` by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2450](grafana/grafana-operator#2450)
- fix(logs): Leader election log format by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2466](grafana/grafana-operator#2466)
- fix: add CRD validation for URLs in external grafana, dashboards, and library panels by [@&#8203;heliapb](https://github.com/heliapb) in [#&#8203;2446](grafana/grafana-operator#2446)
- fix(GrafanaManifest): consider forbidden error as success when deleting manifests by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2468](grafana/grafana-operator#2468)
- fix(helm): missing list namespaces permission with `watchNamespaceSelector` by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2465](grafana/grafana-operator#2465)
- fix(Grafana): missing HTTPRoute backendRefs (alternative solution) by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2510](grafana/grafana-operator#2510)
- fix(GrafanaContactPoint): use list based matching as a workaround for 10.4.0-10.4.5 by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2507](grafana/grafana-operator#2507)

##### Dependencies

- chore(deps): update dependency ko-build/ko to v0.18.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2422](grafana/grafana-operator#2422)
- chore(deps): update dependency kubernetes-sigs/controller-tools to v1.35.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2425](grafana/grafana-operator#2425)
- chore(deps): update dependency kubernetes-sigs/controller-tools to v0.20.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2424](grafana/grafana-operator#2424)
- chore(deps): update docker.io/grafana/grafana docker tag to v12.3.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2423](grafana/grafana-operator#2423)
- fix(deps): update kubernetes packages to v0.35.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2427](grafana/grafana-operator#2427)
- fix(deps): update module github.com/onsi/ginkgo/v2 to v2.27.4 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2434](grafana/grafana-operator#2434)
- fix(deps): update module github.com/onsi/ginkgo/v2 to v2.27.5 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2441](grafana/grafana-operator#2441)
- fix(deps): update module github.com/grafana/grafana-plugin-sdk-go to v0.285.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2444](grafana/grafana-operator#2444)
- chore: bump go to 1.25.6 by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2445](grafana/grafana-operator#2445)
- chore(deps): update dependency kubernetes-sigs/controller-runtime to v0.22.5 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2454](grafana/grafana-operator#2454)
- fix(deps): update module sigs.k8s.io/controller-runtime to v0.22.5 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2455](grafana/grafana-operator#2455)
- chore(deps): update dependency kubernetes-sigs/controller-runtime to v0.23.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2458](grafana/grafana-operator#2458)
- fix(deps): update module sigs.k8s.io/controller-runtime to v0.23.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2459](grafana/grafana-operator#2459)
- fix(deps): update module github.com/grafana/grafana-plugin-sdk-go to v0.286.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2462](grafana/grafana-operator#2462)
- chore(deps): update dependency kubernetes-sigs/controller-runtime to v0.23.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2471](grafana/grafana-operator#2471)
- fix(deps): update module sigs.k8s.io/controller-runtime to v0.23.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2472](grafana/grafana-operator#2472)
- chore(deps): update docker.io/grafana/grafana docker tag to v12.3.2 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2475](grafana/grafana-operator#2475)
- fix(deps): update module github.com/onsi/ginkgo/v2 to v2.28.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2477](grafana/grafana-operator#2477)
- fix(deps): update module github.com/grafana/grafana-plugin-sdk-go to v0.287.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2487](grafana/grafana-operator#2487)
- fix(deps): update module github.com/alecthomas/kong to v1.14.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2488](grafana/grafana-operator#2488)
- fix(deps): update module k8s.io/apimachinery to v0.35.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2492](grafana/grafana-operator#2492)
- chore(deps): update dependency kubernetes-sigs/kustomize to v5.8.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2496](grafana/grafana-operator#2496)
- fix(deps): update kubernetes packages to v0.35.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2498](grafana/grafana-operator#2498)
- fix(deps): update module k8s.io/apiextensions-apiserver to v0.35.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2499](grafana/grafana-operator#2499)
- fix(deps): update module github.com/grafana/grafana-plugin-sdk-go to v0.288.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2500](grafana/grafana-operator#2500)
- chore(deps): update docker.io/grafana/grafana docker tag to v12.3.3 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2502](grafana/grafana-operator#2502)
- fix(deps): update module github.com/grafana/grafana-plugin-sdk-go to v0.288.0 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2505](grafana/grafana-operator#2505)
- chore(deps): update dependency kubernetes-sigs/controller-tools to v0.20.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2509](grafana/grafana-operator#2509)
- chore(deps): update grafana/shared-workflows/get-vault-secrets action to v1.3.1 by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2526](grafana/grafana-operator#2526)
- chore(deps): lock file maintenance by [@&#8203;renovate-sh-app](https://github.com/renovate-sh-app)\[bot] in [#&#8203;2503](grafana/grafana-operator#2503)

##### Documentation

- fix(docs): prefix absolute links in docs by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2421](grafana/grafana-operator#2421)
- fix(docs): git URLs by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2430](grafana/grafana-operator#2430)
- proposal: `GrafanaManifest` resource by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2431](grafana/grafana-operator#2431)
- docs(quickstart): Undisturbed editing with `suspend=true` and link to Common Options by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2451](grafana/grafana-operator#2451)
- proposal: dynamic patching proposal by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2436](grafana/grafana-operator#2436)
- chore(CRDs): `GrafanaManifest` missing and removal of `GrafanaManifestTemplates` by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2473](grafana/grafana-operator#2473)
- docs: document JaaS example by [@&#8203;sebhoss](https://github.com/sebhoss) in [#&#8203;2370](grafana/grafana-operator#2370)
- fix(docs): unified\_alerting.enabled type in multiple replicas example by [@&#8203;klinch0](https://github.com/klinch0) in [#&#8203;2493](grafana/grafana-operator#2493)
- docs: grafana manifest documentation by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2520](grafana/grafana-operator#2520)
- chore: prep-release 5.22.0 by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2528](grafana/grafana-operator#2528)

##### Other Changes

- chore(Makefile): switch deploy target to to its own overlay by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2419](grafana/grafana-operator#2419)
- chore(controllers): move test container creation to tk8s package by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2443](grafana/grafana-operator#2443)
- chore(controllers): Refactor creation of HTTP Clients by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2449](grafana/grafana-operator#2449)
- chore(controllers): normalize logging by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2382](grafana/grafana-operator#2382)
- chore(helm): reduce the number of RBAC resources  by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2464](grafana/grafana-operator#2464)
- chore(RBAC Kustomize/OpenShift): Only allow lease management within the operators current namespace by [@&#8203;Baarsgaard](https://github.com/Baarsgaard) in [#&#8203;2467](grafana/grafana-operator#2467)
- chore(api, controllers): modernize code using Go 1.26 features by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2497](grafana/grafana-operator#2497)
- feat(tests): add support for grafana version overrides  by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2490](grafana/grafana-operator#2490)
- chore(controllers): embed gtime to cut build time by [@&#8203;weisdd](https://github.com/weisdd) in [#&#8203;2514](grafana/grafana-operator#2514)
- refactor: use kyaml instead of simplejson for fieldpath by [@&#8203;theSuess](https://github.com/theSuess) in [#&#8203;2519](grafana/grafana-operator#2519)

#### New Contributors

- [@&#8203;heliapb](https://github.com/heliapb) made their first contribution in [#&#8203;2439](grafana/grafana-operator#2439)
- [@&#8203;RobertClarke64](https://github.com/RobertClarke64) made their first contribution in [#&#8203;2478](grafana/grafana-operator#2478)
- [@&#8203;sebhoss](https://github.com/sebhoss) made their first contribution in [#&#8203;2370](grafana/grafana-operator#2370)
- [@&#8203;klinch0](https://github.com/klinch0) made their first contribution in [#&#8203;2493](grafana/grafana-operator#2493)

**Full Changelog**: <grafana/grafana-operator@v5.21.4...v5.22.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNS43IiwidXBkYXRlZEluVmVyIjoiNDMuMjUuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW1hZ2UiXX0=-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/4201
Co-authored-by: Renovate Bot <renovate-bot@alexlebens.net>
Co-committed-by: Renovate Bot <renovate-bot@alexlebens.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants