[Bug]: Instance manager scans PluginSocketDir only once at startup; a sidecar plugin socket appearing seconds later is permanently missed

Aperta
#11,989 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@somaz94 ci sta già lavorando.

Dal 24/11/2026.

Valutazione

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

Direzione di ricerca

Start at the one-shot scan in internal/cmd/manager/instance/run/cmd.go:264-285 and follow how availablePluginNames is passed into metrics.NewPluginCollector and controller.NewInstanceReconciler. Then read the enabled-plugin intersection in internal/management/controller/instance_controller.go:151-157 and the plugin repository's RegisterUnixSocketPluginsInPath implementation. Reproduce with a sidecar socket created after the postgres container starts; done means an enabled plugin socket appearing later in /plugins is discovered without restarting the container.

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

Descrizione

Is there an existing issue already for this bug?
  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
  • I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
  • I am running a supported version of CloudNativePG.
Version

1.30.1 / 1.30.2 with plugin-barman-cloud v0.15.0; verified on main at e9eec0d as well

What version of Kubernetes are you using?

1.35.7

What is your Kubernetes environment?

Cloud: Azure AKS (with Kata Pod Sandboxing / KataVmIsolation)

How did you install the operator?

Helm

What happened?

The instance manager scans PluginSocketDir (/plugins) only once at process startup (internal/cmd/manager/instance/run/cmd.go:264-285):

pluginRepository := repository.New()
availablePluginNames, err := pluginRepository.RegisterUnixSocketPluginsInPath(
	configuration.Current.PluginSocketDir,
)

That one-shot availablePluginNames slice is captured permanently in both metrics.NewPluginCollector and controller.NewInstanceReconciler. Any sidecar CNPG-i plugin whose Unix socket is created even a few seconds after the postgres container starts is never discovered for the lifetime of the container.

Even though plugin-barman-cloud injects a native sidecar (initContainer with restartPolicy: Always) carrying a startupProbe (/manager healthcheck unix), we observed in production that when a pod sandbox is recreated (e.g., Kata microVM restart) or containers restart concurrently, the postgres container can start before /plugins/barman-cloud.cloudnative-pg.io is listening:

Observed production timeline (2026-10-14):

  • 13:26:22: bootstrap-controller re-ran (pod sandbox recreated).
  • 13:26:23.6: postgres container started and ran RegisterUnixSocketPluginsInPath("/plugins") — socket was not yet present.
  • 13:26:26.6: plugin-barman-cloud sidecar opened /plugins/barman-cloud.cloudnative-pg.io (3 s later).
  • 13:26:25.9 – 13:31:24: On 1.30.x, every reconciliation loop failed with while getting plugin connection: Unknown plugin: barman-cloud.cloudnative-pg.io. PostgreSQL was never started until the 300 s startupProbe killed and restarted the postgres container at 13:31:24 (5 minutes of downtime), after which it immediately found the socket and came up cleanly.

Impact on main (e9eec0d, post-#11858):
In internal/management/controller/instance_controller.go:151-157, the reconciler now intersects cluster.GetInstanceEnabledPluginNames() with the startup availablePluginNames. While that fixes rolling out a newly enabled plugin on pre-existing Pods, if a Pod that does have the sidecar hits this startup race (socket appears 3 s after postgres starts), availablePluginNames stays empty forever — so the instance silently runs without the plugin (missing plugin reconciliation hooks and metrics, or exiting with code 5 on demotion) even though the socket is present in /plugins.

Current workaround:
Wrapping the postgres container command via cnpg.io/podPatch to poll for /plugins/barman-cloud.cloudnative-pg.io (up to 30 s) before exec /controller/manager ....

Expected:
When a Cluster enables a sidecar CNPG-i plugin whose socket is not yet present at startup, the instance manager should either wait/retry scanning PluginSocketDir briefly at startup or lazily re-scan PluginSocketDir when an enabled plugin is missing from pluginRepository (distinguishing between a Pod created without the sidecar vs. a Pod whose sidecar socket has since appeared).

Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: db-example
spec:
  instances: 1
  plugins:
    - name: barman-cloud.cloudnative-pg.io
      isWALArchiver: true
      parameters:
        barmanObjectName: db-example-store
  storage:
    size: 10Gi
Relevant log output
# 2026-10-14 (1.30.1): postgres container started at 13:26:23.6, barman-cloud socket opened at 13:26:26.6
13:26:25.9 ERROR while getting plugin connection: Unknown plugin: barman-cloud.cloudnative-pg.io
# Repeated until startupProbe (1s x 300) restarted the container at 13:31:24
Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
Go
Stelle
9.7k
Fork
826
Merge medio
2g 1h
PR unite (30g)
122

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 cloudnative-pg/cloudnative-pg

Tutte le issue di cloudnative-pg/cloudnative-pg

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.