CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (pull_request) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (push) Successful in 39s
CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (push) Canceled after 0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (push) Successful in 3s
CI / Connect Security-Test-Gate (QA-01 AC4, Merge-Gate) (push) Successful in 3s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (push) Failing after 14s
CI / Web (dms-browser) (push) Failing after 53s
CI / Web (pdf-viewer) (push) Failing after 38s
CI / Web (shl) (push) Failing after 7s
CI / Core-Modul (Build/Vet/Test) (pull_request) Successful in 37s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (pull_request) Successful in 3s
CI / Connect Security-Test-Gate (QA-01 AC4, Merge-Gate) (pull_request) Successful in 2s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (pull_request) Failing after 13s
CI / Web (dms-browser) (pull_request) Failing after 49s
CI / Web (pdf-viewer) (pull_request) Failing after 39s
CI / Web (shl) (pull_request) Failing after 7s
Supply-Chain-Scan (Go) / govulncheck (push) Failing after 1m15s
Core-Schnittstellen-Vertragstests / contract-tests (pull_request) Successful in 13m17s
Supply-Chain-Scan (Go) / govulncheck (pull_request) Failing after 53s
Supply-Chain-Scan (npm) / npm-audit (pull_request) Failing after 1m21s
Core-Pflichttest-Gate / pflichttest-gate (pull_request) Successful in 13m17s
RBAC-Rollenhierarchie-Pflichtgate / rbac-policy-invariant (pull_request) Successful in 12m42s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (push) Canceled after 0s
Dauerhafte Fehler (28P01, 28000, 3D000) beenden mit Exit 2 und klarer Meldung, transiente Fehler werden bis NEXARCH_ACCOUNT_DB_STARTUP_TIMEOUT_SECONDS wiederholt. Unit-Template: RestartSec, StartLimit, RestartPreventExitStatus=2. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
50 lines
939 B
Go
50 lines
939 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
const exitPermanentDBError = 2
|
|
|
|
type pinger interface {
|
|
Ping(ctx context.Context) error
|
|
}
|
|
|
|
func isPermanentDBError(err error) bool {
|
|
var pgErr *pgconn.PgError
|
|
if !errors.As(err, &pgErr) {
|
|
return false
|
|
}
|
|
switch pgErr.Code {
|
|
case "28000", "28P01", "3D000":
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func waitForDB(ctx context.Context, p pinger, timeout time.Duration, sleep func(time.Duration)) error {
|
|
deadline := time.Now().Add(timeout)
|
|
delay := time.Second
|
|
for {
|
|
err := p.Ping(ctx)
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
if isPermanentDBError(err) {
|
|
return fmt.Errorf("datenbank lehnt Anmeldung oder Datenbank ab (dauerhaft): %w", err)
|
|
}
|
|
if time.Now().Add(delay).After(deadline) {
|
|
return fmt.Errorf("datenbank nach %s nicht erreichbar: %w", timeout, err)
|
|
}
|
|
sleep(delay)
|
|
if delay < 30*time.Second {
|
|
delay *= 2
|
|
}
|
|
}
|
|
}
|