fix: relax v03 external postgres startup timeouts (#2190)
This commit is contained in:
+36
-3
@@ -353,7 +353,7 @@ lanes:
|
|||||||
timeoutMs: 3000
|
timeoutMs: 3000
|
||||||
sessionsSummary:
|
sessionsSummary:
|
||||||
maxAttempts: 1
|
maxAttempts: 1
|
||||||
attemptTimeoutMs: 2500
|
attemptTimeoutMs: 10000
|
||||||
backoffMs: 0
|
backoffMs: 0
|
||||||
factsQuery:
|
factsQuery:
|
||||||
maxAttempts: 1
|
maxAttempts: 1
|
||||||
@@ -361,8 +361,8 @@ lanes:
|
|||||||
backoffMaxMs: 1
|
backoffMaxMs: 1
|
||||||
postgres:
|
postgres:
|
||||||
poolMax: 16
|
poolMax: 16
|
||||||
queryTimeoutMs: 3000
|
queryTimeoutMs: 10000
|
||||||
readyTimeoutMs: 2000
|
readyTimeoutMs: 10000
|
||||||
cache:
|
cache:
|
||||||
redis:
|
redis:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -473,6 +473,16 @@ lanes:
|
|||||||
artifactKind: go-service
|
artifactKind: go-service
|
||||||
healthPath: /health/ready
|
healthPath: /health/ready
|
||||||
healthPort: 6671
|
healthPort: 6671
|
||||||
|
healthProbe:
|
||||||
|
readiness:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 5
|
||||||
|
liveness:
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
startup:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 30
|
||||||
componentPaths:
|
componentPaths:
|
||||||
- go.mod
|
- go.mod
|
||||||
- go.sum
|
- go.sum
|
||||||
@@ -488,6 +498,16 @@ lanes:
|
|||||||
artifactKind: go-service
|
artifactKind: go-service
|
||||||
healthPath: /health/ready
|
healthPath: /health/ready
|
||||||
healthPort: 6670
|
healthPort: 6670
|
||||||
|
healthProbe:
|
||||||
|
readiness:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 5
|
||||||
|
liveness:
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
startup:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 30
|
||||||
componentPaths:
|
componentPaths:
|
||||||
- go.mod
|
- go.mod
|
||||||
- go.sum
|
- go.sum
|
||||||
@@ -503,6 +523,16 @@ lanes:
|
|||||||
artifactKind: bun-command
|
artifactKind: bun-command
|
||||||
healthPath: /health/ready
|
healthPath: /health/ready
|
||||||
healthPort: 6672
|
healthPort: 6672
|
||||||
|
healthProbe:
|
||||||
|
readiness:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 5
|
||||||
|
liveness:
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
startup:
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 30
|
||||||
componentPaths:
|
componentPaths:
|
||||||
- cmd/hwlab-project-management/
|
- cmd/hwlab-project-management/
|
||||||
- internal/project-management/
|
- internal/project-management/
|
||||||
@@ -751,6 +781,8 @@ lanes:
|
|||||||
env:
|
env:
|
||||||
HWLAB_USER_BILLING_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
HWLAB_USER_BILLING_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
||||||
HWLAB_USER_BILLING_DB_POOL_MAX: "2"
|
HWLAB_USER_BILLING_DB_POOL_MAX: "2"
|
||||||
|
HWLAB_USER_BILLING_MIGRATION_TIMEOUT_SECONDS: "180"
|
||||||
|
HWLAB_USER_BILLING_BOOTSTRAP_TIMEOUT_SECONDS: "60"
|
||||||
HWLAB_BOOTSTRAP_ADMIN_ID: usr_v03_admin
|
HWLAB_BOOTSTRAP_ADMIN_ID: usr_v03_admin
|
||||||
HWLAB_BOOTSTRAP_ADMIN_USERNAME: admin
|
HWLAB_BOOTSTRAP_ADMIN_USERNAME: admin
|
||||||
HWLAB_BOOTSTRAP_ADMIN_DISPLAY_NAME: HWLAB v0.3 Admin
|
HWLAB_BOOTSTRAP_ADMIN_DISPLAY_NAME: HWLAB v0.3 Admin
|
||||||
@@ -769,6 +801,7 @@ lanes:
|
|||||||
replicas: 1
|
replicas: 1
|
||||||
env:
|
env:
|
||||||
HWLAB_PROJECT_MANAGEMENT_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
HWLAB_PROJECT_MANAGEMENT_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
|
||||||
|
HWLAB_PROJECT_MANAGEMENT_DB_CONNECT_TIMEOUT_MS: "5000"
|
||||||
HWLAB_PROJECT_MANAGEMENT_PORT: "6672"
|
HWLAB_PROJECT_MANAGEMENT_PORT: "6672"
|
||||||
HWLAB_PROJECT_MANAGEMENT_SOURCE_ROOT: /workspace/hwlab-boot/repo
|
HWLAB_PROJECT_MANAGEMENT_SOURCE_ROOT: /workspace/hwlab-boot/repo
|
||||||
HWLAB_PROJECT_MANAGEMENT_SOURCE_ID: hwlab-v03-mdtodo
|
HWLAB_PROJECT_MANAGEMENT_SOURCE_ID: hwlab-v03-mdtodo
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ type Config struct {
|
|||||||
InternalToken string
|
InternalToken string
|
||||||
RequireInternalToken bool
|
RequireInternalToken bool
|
||||||
MigrateOnStart bool
|
MigrateOnStart bool
|
||||||
|
MigrationTimeout time.Duration
|
||||||
|
BootstrapTimeout time.Duration
|
||||||
StateAuthority string
|
StateAuthority string
|
||||||
RuntimeNamespace string
|
RuntimeNamespace string
|
||||||
ExternalDatabaseLabel string
|
ExternalDatabaseLabel string
|
||||||
@@ -332,6 +334,8 @@ func LoadConfig(env []string) Config {
|
|||||||
InternalToken: values["HWLAB_USER_BILLING_INTERNAL_TOKEN"],
|
InternalToken: values["HWLAB_USER_BILLING_INTERNAL_TOKEN"],
|
||||||
RequireInternalToken: values["HWLAB_USER_BILLING_REQUIRE_INTERNAL_TOKEN"] == "1",
|
RequireInternalToken: values["HWLAB_USER_BILLING_REQUIRE_INTERNAL_TOKEN"] == "1",
|
||||||
MigrateOnStart: values["HWLAB_USER_BILLING_MIGRATE_ON_START"] != "0",
|
MigrateOnStart: values["HWLAB_USER_BILLING_MIGRATE_ON_START"] != "0",
|
||||||
|
MigrationTimeout: parseDurationSeconds(values["HWLAB_USER_BILLING_MIGRATION_TIMEOUT_SECONDS"], 20),
|
||||||
|
BootstrapTimeout: parseDurationSeconds(values["HWLAB_USER_BILLING_BOOTSTRAP_TIMEOUT_SECONDS"], 10),
|
||||||
StateAuthority: first(values["HWLAB_USER_BILLING_STATE_AUTHORITY"], "pk01-postgres"),
|
StateAuthority: first(values["HWLAB_USER_BILLING_STATE_AUTHORITY"], "pk01-postgres"),
|
||||||
RuntimeNamespace: first(values["POD_NAMESPACE"], values["HWLAB_NAMESPACE"], "hwlab-v03"),
|
RuntimeNamespace: first(values["POD_NAMESPACE"], values["HWLAB_NAMESPACE"], "hwlab-v03"),
|
||||||
ExternalDatabaseLabel: first(values["HWLAB_USER_BILLING_EXTERNAL_DB_LABEL"], "pk01-external-postgres"),
|
ExternalDatabaseLabel: first(values["HWLAB_USER_BILLING_EXTERNAL_DB_LABEL"], "pk01-external-postgres"),
|
||||||
@@ -357,13 +361,13 @@ func NewServer(ctx context.Context, cfg Config) (*Server, error) {
|
|||||||
db.SetConnMaxLifetime(30 * time.Minute)
|
db.SetConnMaxLifetime(30 * time.Minute)
|
||||||
server.db = db
|
server.db = db
|
||||||
if cfg.MigrateOnStart {
|
if cfg.MigrateOnStart {
|
||||||
migrateCtx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
migrateCtx, cancel := context.WithTimeout(ctx, durationOrDefault(cfg.MigrationTimeout, 20*time.Second))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := server.migrate(migrateCtx); err != nil {
|
if err := server.migrate(migrateCtx); err != nil {
|
||||||
return nil, fmt.Errorf("migrate user billing schema: %w", err)
|
return nil, fmt.Errorf("migrate user billing schema: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bootstrapCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
bootstrapCtx, cancel := context.WithTimeout(ctx, durationOrDefault(cfg.BootstrapTimeout, 10*time.Second))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := server.ensureBootstrapAdmin(bootstrapCtx); err != nil {
|
if err := server.ensureBootstrapAdmin(bootstrapCtx); err != nil {
|
||||||
return nil, fmt.Errorf("ensure bootstrap admin: %w", err)
|
return nil, fmt.Errorf("ensure bootstrap admin: %w", err)
|
||||||
@@ -2941,6 +2945,17 @@ func parseDurationMinutes(value string, fallbackMinutes int64) time.Duration {
|
|||||||
return time.Duration(parseInt64(value, fallbackMinutes)) * time.Minute
|
return time.Duration(parseInt64(value, fallbackMinutes)) * time.Minute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseDurationSeconds(value string, fallbackSeconds int64) time.Duration {
|
||||||
|
return time.Duration(parseInt64(value, fallbackSeconds)) * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
|
func durationOrDefault(value time.Duration, fallback time.Duration) time.Duration {
|
||||||
|
if value <= 0 {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
func first(values ...string) string {
|
func first(values ...string) string {
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
if strings.TrimSpace(value) != "" {
|
if strings.TrimSpace(value) != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user