Skip to content

plan: configure global loggers once, not on every reconcile#66

Open
tamalsaha wants to merge 1 commit into
masterfrom
refactor/plan-no-global-mutation
Open

plan: configure global loggers once, not on every reconcile#66
tamalsaha wants to merge 1 commit into
masterfrom
refactor/plan-no-global-mutation

Conversation

@tamalsaha

Copy link
Copy Markdown
Contributor

Summary

SetDNSRecords mutated process-wide state on every reconcile:

  • annotations.SetAnnotationPrefix(...) — but the operator never reads a custom prefix from the CR. The setter was always being called with the upstream default. Removed.
  • configureLogger(...) — re-set logrus level/format on every call. Two ExternalDNS resources with different log settings would race. Guarded with sync.Once.

Test plan

  • go build ./...
  • Confirm log level/format from the first reconcile persists and is not overwritten by later reconciles

SetDNSRecords used to call annotations.SetAnnotationPrefix() and
configureLogger() on every reconcile. Both mutate process-wide state in
external-dns / logrus. Two ExternalDNS resources with different log
settings (or, in the future, different annotation prefixes) would race
and last-writer-win.

- Drop the annotations.SetAnnotationPrefix call: the operator never reads
  an annotation-prefix from the CR; the value is always the upstream
  default already wired in defaultConfig, so calling the setter every
  reconcile is dead work that also pokes a global.
- Guard configureLogger with sync.Once so the first reconcile fixes the
  log level/format and subsequent reconciles cannot flip them.

Signed-off-by: Tamal Saha <tamal@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant