[BUG] kubernetes sync: watch errors bypass flagd's logger and metrics

Aperta
#2,104 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Hrushikesh-ramilla ci sta già lavorando.

Dal 26/10/2026.

  • #2110 di @Hrushikesh-ramilla — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go, kubernetes

Direzione di ricerca

Start with core/pkg/sync/kubernetes/kubernetes_sync.go around the readiness registration at line 172, then inspect where the informer is created and run. Check how flagd logging and sync error metrics are exposed, and whether SetWatchErrorHandler can be registered before Run. Done when watch failures reach flagd's logger and an appropriate metric, with tests covering the handler.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Observed behavior

When the Kubernetes sync loses its watch after startup (RBAC removed, API server unreachable), the dynamic informer retries forever. The failures are reported only by client-go through klog to stderr, for example:

Failed to watch *unstructured.Unstructured: ... featureflags.core.openfeature.dev is forbidden: User "system:serviceaccount:flagd:flagd" cannot list resource ... logger="UnhandledError"

Nothing goes through flagd's logger, and no metric changes. Combined with the latched readiness (monitoring docs), flagd keeps serving the last flags it read with no signal that the source is gone.

The sync is marked ready once, when the event handler is registered, and never cleared (kubernetes_sync.go#L172).

Expected behavior

Watch errors are logged through flagd's logger, and ideally counted in a sync error metric, so the failure can be alerted on without scraping stderr.

A possible approach: register informer.SetWatchErrorHandler (must be set before Run) to log via flagd's logger and increment a metric. The same hook could later drive readiness, if the outcome of the discussion in #2017 is that a failed sync should affect health.

Steps to reproduce
  1. Run flagd (v0.17.0, same code on main) with --uri=core.openfeature.dev/<ns>/<name> and a Role granting get/list/watch on featureflags, bound to its service account.
  2. Wait for /readyz to return 200.
  3. Delete the RoleBinding.
  4. The pod stays Ready; the errors appear only on stderr.

Happy to open a PR if this approach sounds right.

Lingua principale
Go
Stelle
1k
Fork
151
Merge medio
5g 5h
PR unite (30g)
14

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di open-feature/flagd

Tutte le issue di open-feature/flagd

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.