BReg: retry a refused first database connection in one-shot operations

Aperta Adatta ai principianti
#2,765 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
postgresql, rust
Ambito
databases

Direzione di ricerca

Parti da connect_dedicated in crates/registry-breg/src/postgres/interlock.rs e leggi come lo chiamano i comandi one-shot (status, doctor, plan, apply, instance-claim), oltre a come l'errore di connessione di sqlx espone una connessione rifiutata/irraggiungibile. Scegli una finestra limitata (l'issue suggerisce 10 s) e riprova solo gli errori sollevati prima che venga inviata qualsiasi istruzione. Un test che dimostri che una prima connessione rifiutata viene ritentata mentre un errore a metà di un'istruzione non viene ritentato è ciò che significa 'done'; nota che l'issue lascia aperta l'Opzione 2 basata su chart, quindi conferma l'approccio prima di scrivere codice.

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

Descrizione

area:breg enhancement

Operation Jobs in the Helm chart run one attempt (backoffLimit: 0), so the operator's reconcile-first refusal decides what happens next rather than a Kubernetes retry. With one attempt, a failed first database connection fails the whole operation, and the operator has to rerun it.

On a single-server K3s install, a newly started Pod labelled registrystack.org/database-client: "true" got Connection refused from PostgreSQL for about 600 ms before its first successful TCP connection. The K3s network policy controller admits a new Pod's address shortly after the container starts. No BReg Job failed in that run, probably because the stage-operation-inputs init container delays the bregctl container. That margin is a matter of timing, not something the design guarantees.

status and the maintenance interlock connect through connect_dedicated in crates/registry-breg/src/postgres/interlock.rs, which makes one attempt and has no retry.

Options:

  1. Give the one-shot maintenance commands (status, doctor, plan, apply, instance-claim) a short bounded retry, for example up to 10 s, that covers only connection refused or unreachable before any statement is sent. Nothing has changed in the database at that point, so the retry cannot repeat work.
  2. Add a wait for the database port to the operation Job's init container. This stays in the chart and covers only Kubernetes installs.

Option 1 also helps any other orchestrator that starts a fresh process next to a fresh network policy.

Lingua principale
Rust
Stelle
2
Fork
0
Merge medio
9h 48m
PR unite (30g)
151

Preparare l'ambiente

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 registrystack/registry-stack

Tutte le issue di registrystack/registry-stack

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.