mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-29 00:01:22 +00:00
feat: persist scaling policies to Postgres
Adds scaling_policies table and wires the autoscaler: upsert on every SetScalingPolicy (including delete-as-disable), LoadPolicies hydrates policies + service states at boot. Persist failures are logged, never fatal — in-memory state stays authoritative. Verified live: policy written on POST, survives a full backend restart, service state re-registers at min_replicas. Also gofmt-fixes the drifted databases.go struct tags. Authored By: TDvorak <[email protected]> Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
b61203f908
commit
25e4f676a9
5 files changed
+169
-23
No files matched your search
@@ -48,6 +48,12 @@ func SetupRoutes(router *gin.Engine, db *database.DB, redis *database.Redis, cfg
|
||||
}
|
||||
metricsCollector := metrics.NewMetricsCollector(scheduler, metricsStorage)
|
||||
autoScaler := scaling.NewAutoScaler(scheduler, metricsCollector)
|
||||
if db != nil && db.DB != nil {
|
||||
autoScaler.WithPersistence(db.DB)
|
||||
if err := autoScaler.LoadPolicies(context.Background()); err != nil {
|
||||
log.Printf("Failed to restore scaling policies: %v", err)
|
||||
}
|
||||
}
|
||||
haManager := ha.NewHighAvailabilityManager(scheduler, metricsCollector)
|
||||
haAPIManager := NewHAManager(haManager)
|
||||
|
||||
|
||||
Reference in new issue
Block a user