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

Refactor: Reconcile loggers, prepare for concurrent reconcilers #1836

Conversation

Baarsgaard
Copy link
Contributor

@Baarsgaard Baarsgaard commented Jan 23, 2025

Was looking to implement an option for configuring MaxConcurrentReconciles when registering controllers.
But realised that the Reconciler structs seem to be shared across reconcile requests, meaning r.Log could be replaced with context values from a later reconcileRequest.
This is especially likely for GrafanaContactPoints due to the Watches in GrafanaNotificationPolicy.

Kubebuilder suggests using the plain log := log.FromContext(ctx)

Kubebuilder recommends to always have the ctx as the first argument and I have ensured that is the case as much as possible: kubebuilder controller-implementation

@github-actions github-actions bot added the refactor this PR refactors code without introducing functionality label Jan 23, 2025
@Baarsgaard Baarsgaard force-pushed the refactor_reconcile_loggers_prep_concurrent_reconciles branch from eb0e9ca to c2d45cb Compare January 23, 2025 18:10
@Baarsgaard Baarsgaard marked this pull request as ready for review January 23, 2025 18:17
@Baarsgaard Baarsgaard force-pushed the refactor_reconcile_loggers_prep_concurrent_reconciles branch from c2d45cb to d7d80cf Compare January 25, 2025 13:10
@theSuess
Copy link
Member

I think this would be even cleaner by only passing the context and having the logger stored there

@Baarsgaard Baarsgaard force-pushed the refactor_reconcile_loggers_prep_concurrent_reconciles branch from d7d80cf to 519c7fd Compare January 27, 2025 18:32
controllers/controller_shared_test.go Outdated Show resolved Hide resolved
@Baarsgaard Baarsgaard requested a review from theSuess January 28, 2025 18:40
@theSuess theSuess added this pull request to the merge queue Jan 29, 2025
Merged via the queue into grafana:master with commit ef50d95 Jan 29, 2025
15 checks passed
@Baarsgaard Baarsgaard deleted the refactor_reconcile_loggers_prep_concurrent_reconciles branch January 29, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor this PR refactors code without introducing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants