fix: keep track of old scale values for a single deploy

This will ensure we scale things down after usage.
This commit is contained in:
Jose Diaz-Gonzalez
2022-11-27 15:02:45 -05:00
parent 7cc3f33590
commit e458c8e4a6
2 changed files with 26 additions and 1 deletions

View File

@@ -186,7 +186,22 @@ func getFormations(appName string) (FormationSlice, error) {
return formations, err return formations, err
} }
return parseProcessTuples(processTuples) oldProcessTuples, err := common.PropertyListGet("ps", appName, "scale.old")
if err != nil {
return formations, err
}
formations, err = parseProcessTuples(processTuples)
if err != nil {
return formations, err
}
oldFormations, err := parseProcessTuples(oldProcessTuples)
if err != nil {
return formations, err
}
return append(formations, oldFormations...), nil
} }
func restorePrep() error { func restorePrep() error {
@@ -335,13 +350,19 @@ func updateScale(appName string, clearExisting bool, formationUpdates FormationS
} }
values := []string{} values := []string{}
oldValues := []string{}
for _, formation := range updatedFormation { for _, formation := range updatedFormation {
if !validProcessTypes[formation.ProcessType] && formation.Quantity == 0 { if !validProcessTypes[formation.ProcessType] && formation.Quantity == 0 {
oldValues = append(oldValues, fmt.Sprintf("%s=%d", formation.ProcessType, formation.Quantity))
continue continue
} }
values = append(values, fmt.Sprintf("%s=%d", formation.ProcessType, formation.Quantity)) values = append(values, fmt.Sprintf("%s=%d", formation.ProcessType, formation.Quantity))
} }
if err := common.PropertyListWrite("ps", appName, "scale.old", oldValues); err != nil {
return err
}
return common.PropertyListWrite("ps", appName, "scale", values) return common.PropertyListWrite("ps", appName, "scale", values)
} }

View File

@@ -42,6 +42,10 @@ func TriggerCorePostDeploy(appName string) error {
} }
} }
if err := common.PropertyDelete("ps", appName, "scale.old"); err != nil {
return err
}
entries := map[string]string{ entries := map[string]string{
"DOKKU_APP_RESTORE": "1", "DOKKU_APP_RESTORE": "1",
} }