Skip to content
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

[Bug] Operator shouldn't need to modify Service Accounts, and/or shouldn't need to add a label to them #1782

Closed
cmi4 opened this issue Dec 3, 2024 · 2 comments
Labels
bug Something isn't working stale triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@cmi4
Copy link
Contributor

cmi4 commented Dec 3, 2024

Describe the bug
In some contexts, for security reasons Grafana Operator shouldn't have access to modify ServiceAccount resources, and thus there should be an option for it to skip reconciliation of ServiceAccount resources.

This manifests itself starting with #1661 which adds a label to every resource, including ServiceAccount. As a stopgap, it would be fine to be able to avoid adding that label.

2024-12-03T07:00:10Z	INFO	GrafanaReconciler	running stage	{"controller": "grafana", "controllerGroup": "grafana.integreatly.org", "controllerKind": "Grafana", "Grafana": {"name":"grafana","namespace":"grafana"}, "namespace": "grafana", "name": "grafana", "reconcileID": "96ddf732-a581-40d3-849b-739cf6270357", "stage": "service account"}
2024-12-03T07:00:10Z	ERROR	GrafanaReconciler	reconciler error in stage	{"controller": "grafana", "controllerGroup": "grafana.integreatly.org", "controllerKind": "Grafana", "Grafana": {"name":"grafana","namespace":"grafana"}, "namespace": "grafana", "name": "grafana", "reconcileID": "96ddf732-a581-40d3-849b-739cf6270357", "stage": "service account", "error": "serviceaccounts \"grafana-sa\" is forbidden: User \"system:serviceaccount:grafana:grafana-operator-controller-manager\" cannot update resource \"serviceaccounts\" in API group \"\" in the namespace \"grafana\""}
github.com/grafana/grafana-operator/v5/controllers.(*GrafanaReconciler).Reconcile
2024-12-03T07:00:10Z	INFO	GrafanaReconciler	stage in progress	{"controller": "grafana", "controllerGroup": "grafana.integreatly.org", "controllerKind": "Grafana", "Grafana": {"name":"grafana","namespace":"grafana"}, "namespace": "grafana", "name": "grafana", "reconcileID": "96ddf732-a581-40d3-849b-739cf6270357", "stage": "service account"}

Version
v5.15.1, but starts in v5.13.0

To Reproduce
Steps to reproduce the behavior:

Set up Grafana Operator without API access to serviceaccounts. Run Grafana Operator and observe problem.

Expected behavior
It should be possible to either exclude ServiceAccount resources from reconciliation, or elect not to add the CommonLabels to the service accounts (or to any resources)

Suspect component/Location where the bug might be occurring
GrafanaReconciler, service account stage

@cmi4 cmi4 added bug Something isn't working needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 3, 2024
@theSuess
Copy link
Member

theSuess commented Dec 9, 2024

Thanks for reporting this issue. I'll provide some more context here to illustrate why labeling the service account is necessary.

In #1622 we analyzed memory usage of the operator and realized that we excessively cache resources which leads to OOM errors in some situations.
To address this, the best way is by selectively caching resources based on labels. This is why #1661 adds logic to add a new label to all resources we manage.

Ideally, we want to avoid adding special cases for ignoring some resources, but I see where your desire to limit the permissions come from. Can you try adding the "app.kubernetes.io/managed-by": "grafana-operator", label to the service account manually and see if the error still shows up?

Note that this will only be relevant for existing resources. Newly created service accounts shouldn't need any updates as they'll have the label present at creation.

@theSuess theSuess added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 9, 2024
Copy link

github-actions bot commented Jan 9, 2025

This issue hasn't been updated for a while, marking as stale, please respond within the next 7 days to remove this label

@github-actions github-actions bot added the stale label Jan 9, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

2 participants