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:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user