fix: handle scaling properly when there is no procfile

This commit is contained in:
Jose Diaz-Gonzalez committed 2020-11-21 20:57:33 -05:00
1 parent 833a64cc0e
commit bf84405b43
2 files changed
+19 -9

No files matched your search

+10 -8
View File
@@ -223,9 +223,13 @@ func updateScalefile(appName string, processTuples []string) error {
return err return err
} }
processTypes, err := processesInProcfile(procfilePath) processTypes := make(map[string]bool)
if err != nil { hasProcfile := common.FileExists(procfilePath)
return err if hasProcfile {
processTypes, err = processesInProcfile(procfilePath)
if err != nil {
return err
}
} }
newLines := []string{} newLines := []string{}
@@ -257,10 +261,8 @@ func updateScalefile(appName string, processTuples []string) error {
return fmt.Errorf("Invalid count for process type %s", s[0]) return fmt.Errorf("Invalid count for process type %s", s[0])
} }
if _, ok := processTypes[processType]; !ok { if _, ok := processTypes[processType]; !ok && hasProcfile && count != 0 {
if count != 0 && len(processTypes) == 0 { return fmt.Errorf("%s is not a valid process name to scale up", processType)
return fmt.Errorf("%s is not a valid process name to scale up", processType)
}
} }
scale = append(scale, fmt.Sprintf("%s=%d", processType, count)) 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 err return nil
} }
+9 -1
View File
@@ -104,7 +104,10 @@ func CommandScale(appName string, processTuples []string) error {
scalefilePath := getScalefilePath(appName) scalefilePath := getScalefilePath(appName)
if !common.FileExists(procfilePath) { if !common.FileExists(procfilePath) {
image := common.GetAppImageRepo(appName) image := common.GetAppImageRepo(appName)
extractProcfile(appName, image, procfilePath) common.SuppressOutput(func() error {
extractProcfile(appName, image, procfilePath)
return nil
})
} }
if !common.FileExists(scalefilePath) { 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) 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 { if err := updateScalefile(appName, processTuples); err != nil {
return err return err
} }
if !common.IsDeployed(appName) {
return nil
}
imageTag, err := common.GetRunningImageTag(appName) imageTag, err := common.GetRunningImageTag(appName)
if err != nil { if err != nil {
return err return err