From bf84405b4321d3ab5e4ec6bfc22827d9dd6c4db6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 2 Nov 2020 08:18:42 -0500 Subject: [PATCH] fix: handle scaling properly when there is no procfile --- plugins/ps/functions.go | 18 ++++++++++-------- plugins/ps/subcommands.go | 10 +++++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/ps/functions.go b/plugins/ps/functions.go index d276d8437..9b08842b7 100644 --- a/plugins/ps/functions.go +++ b/plugins/ps/functions.go @@ -223,9 +223,13 @@ func updateScalefile(appName string, processTuples []string) error { return err } - processTypes, err := processesInProcfile(procfilePath) - if err != nil { - return err + processTypes := make(map[string]bool) + hasProcfile := common.FileExists(procfilePath) + if hasProcfile { + processTypes, err = processesInProcfile(procfilePath) + if err != nil { + return err + } } newLines := []string{} @@ -257,10 +261,8 @@ func updateScalefile(appName string, processTuples []string) error { return fmt.Errorf("Invalid count for process type %s", s[0]) } - if _, ok := processTypes[processType]; !ok { - if count != 0 && len(processTypes) == 0 { - return fmt.Errorf("%s is not a valid process name to scale up", processType) - } + if _, ok := processTypes[processType]; !ok && hasProcfile && count != 0 { + return fmt.Errorf("%s is not a valid process name to scale up", processType) } scale = append(scale, fmt.Sprintf("%s=%d", processType, count)) @@ -288,5 +290,5 @@ func updateScalefile(appName string, processTuples []string) error { return err } - return err + return nil } diff --git a/plugins/ps/subcommands.go b/plugins/ps/subcommands.go index 352e3ae78..4438c34c4 100644 --- a/plugins/ps/subcommands.go +++ b/plugins/ps/subcommands.go @@ -104,7 +104,10 @@ func CommandScale(appName string, processTuples []string) error { scalefilePath := getScalefilePath(appName) if !common.FileExists(procfilePath) { image := common.GetAppImageRepo(appName) - extractProcfile(appName, image, procfilePath) + common.SuppressOutput(func() error { + extractProcfile(appName, image, procfilePath) + return nil + }) } if !common.FileExists(scalefilePath) { @@ -152,10 +155,15 @@ func CommandScale(appName string, processTuples []string) error { return fmt.Errorf("App %s contains DOKKU_SCALE file and cannot be manually scaled", appName) } + common.LogInfo1(fmt.Sprintf("Scaling %s processes: %s", appName, strings.Join(processTuples, " "))) if err := updateScalefile(appName, processTuples); err != nil { return err } + if !common.IsDeployed(appName) { + return nil + } + imageTag, err := common.GetRunningImageTag(appName) if err != nil { return err