fix: reference extracted Procfile

Rather than attempting to always extract the Procfile, reference the one that was extracted by the last deploy. This fixes issues where 'docker container cp' may fail intermittently for lord knows what reason.

Closes #4083
This commit is contained in:
Jose Diaz-Gonzalez
2020-11-22 17:12:51 -05:00
parent e0127250ae
commit fceb412fb1
5 changed files with 28 additions and 46 deletions

View File

@@ -1511,7 +1511,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
- Description: Removes the extracted Procfile
- Invoked by: `internally`
- Arguments: `$APP $PROCFILE_PATH`
- Arguments: `$APP`
- Example:
```shell

View File

@@ -19,11 +19,7 @@ func canScaleApp(appName string) bool {
return !common.FileExists(getScalefileExtractedPath(appName))
}
func extractProcfile(appName, image string, procfilePath string) error {
if err := removeProcfile(appName); err != nil {
return err
}
func extractProcfile(appName, image string) error {
destination := getProcfilePath(appName)
common.CopyFromImage(appName, image, "Procfile", destination)
if !common.FileExists(destination) {

View File

@@ -62,8 +62,7 @@ func main() {
err = ps.TriggerProcfileGetCommand(appName, processType, port)
case "procfile-remove":
appName := flag.Arg(0)
procfilePath := flag.Arg(1)
err = ps.TriggerProcfileRemove(appName, procfilePath)
err = ps.TriggerProcfileRemove(appName)
case "report":
appName := flag.Arg(0)
err = ps.ReportSingleApp(appName, "")

View File

@@ -144,11 +144,14 @@ func CommandScale(appName string, skipDeploy bool, processTuples []string) error
procfilePath := getProcfilePath(appName)
if !common.FileExists(procfilePath) {
image := common.GetAppImageRepo(appName)
common.SuppressOutput(func() error {
extractProcfile(appName, image, procfilePath)
return nil
})
extract := func() error {
image := common.GetDeployingAppImageName(appName, "", "")
return extractProcfile(appName, image)
}
if err := common.SuppressOutput(extract); err != nil {
return err
}
}
if !hasScaleFile(appName) {

View File

@@ -17,13 +17,9 @@ func TriggerAppRestart(appName string) error {
return Restart(appName)
}
// TriggerCorePostDeploy removes extracted procfiles
// and sets a property to allow the app to be restored on boot
// TriggerCorePostDeploy sets a property to
// allow the app to be restored on boot
func TriggerCorePostDeploy(appName string) error {
if err := removeProcfile(appName); err != nil {
return err
}
entries := map[string]string{
"DOKKU_APP_RESTORE": "1",
}
@@ -148,11 +144,12 @@ func TriggerPostStop(appName string) error {
// TriggerPreDeploy ensures an app has an up to date scale file
func TriggerPreDeploy(appName string, imageTag string) error {
image := common.GetAppImageRepo(appName)
removeProcfile(appName)
image := common.GetDeployingAppImageName(appName, imageTag, "")
if err := removeProcfile(appName); err != nil {
return err
}
procfilePath := getProcfilePath(appName)
if err := extractProcfile(appName, image, procfilePath); err != nil {
if err := extractProcfile(appName, image); err != nil {
return err
}
@@ -174,27 +171,23 @@ func TriggerProcfileExtract(appName string, image string) error {
return err
}
procfilePath := getProcfilePath(appName)
if common.FileExists(procfilePath) {
if err := common.PlugnTrigger("procfile-remove", []string{appName, procfilePath}...); err != nil {
return err
}
if err := removeProcfile(appName); err != nil {
return err
}
return extractProcfile(appName, image, procfilePath)
return extractProcfile(appName, image)
}
// TriggerProcfileGetCommand fetches a command from the procfile
func TriggerProcfileGetCommand(appName string, processType string, port int) error {
procfilePath := getProcfilePath(appName)
if !common.FileExists(procfilePath) {
image := common.GetDeployingAppImageName(appName, "", "")
err := common.SuppressOutput(func() error {
return common.PlugnTrigger("procfile-extract", []string{appName, image}...)
})
extract := func() error {
image := common.GetDeployingAppImageName(appName, "", "")
return extractProcfile(appName, image)
}
if err != nil {
if err := common.SuppressOutput(extract); err != nil {
return err
}
}
@@ -211,15 +204,6 @@ func TriggerProcfileGetCommand(appName string, processType string, port int) err
}
// TriggerProcfileRemove removes the procfile if it exists
func TriggerProcfileRemove(appName string, procfilePath string) error {
if procfilePath == "" {
procfilePath = getProcfilePath(appName)
}
if !common.FileExists(procfilePath) {
return nil
}
os.Remove(procfilePath)
return nil
func TriggerProcfileRemove(appName string) error {
return removeProcfile(appName)
}