From 30a15aaa7ac2b553681e455343e414b3b9111f76 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 5 Aug 2021 04:16:49 -0400 Subject: [PATCH] fix: respect pre-deploy task image manipulation This requires a bc-incompatible break in terms of what triggers the pre-deploy hook (dokku internals vs schedulers). --- docs/appendices/0.25.0-migration-guide.md | 1 + plugins/app-json/triggers.go | 6 +----- plugins/common/functions | 3 ++- plugins/config/docker-args-deploy | 2 +- plugins/ps/triggers.go | 5 +---- plugins/scheduler-docker-local/pre-deploy | 2 +- plugins/scheduler-docker-local/scheduler-deploy | 1 - 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/docs/appendices/0.25.0-migration-guide.md b/docs/appendices/0.25.0-migration-guide.md index f61892a97..76dd350f8 100644 --- a/docs/appendices/0.25.0-migration-guide.md +++ b/docs/appendices/0.25.0-migration-guide.md @@ -15,6 +15,7 @@ The [dokku-registry](https://github.com/dokku/dokku-registry) plugin is now buil - The network plugin can now set an `initial-network` for all containers on creation. This is a replacement for specifying the `--network` flag via the `docker-options` plugin. Please see the [network documentation](/docs/networking/network.md#attaching-an-app-to-a-network) for more information. - The `dokku run` command now always removes the ephemeral container on exit. Users that need a persistent container should instead specify a `console` process type in their `Procfile` specifying an available shell (usually either `bash` or `sh`) and scale that container appropriately. +- The `pre-deploy` plugin trigger is now called internally by Dokku. Scheduler plugins should avoid calling this trigger, as any image changes introduced by subsequent trigger calls will be ignored. ### Deprecations diff --git a/plugins/app-json/triggers.go b/plugins/app-json/triggers.go index 708a5583b..a18707640 100644 --- a/plugins/app-json/triggers.go +++ b/plugins/app-json/triggers.go @@ -47,11 +47,7 @@ func TriggerPostDeploy(appName string, imageTag string) error { // TriggerPreDeploy is a trigger to execute predeploy and release deployment tasks func TriggerPreDeploy(appName string, imageTag string) error { - image, err := common.GetDeployingAppImageName(appName, imageTag, "") - if err != nil { - return err - } - + image := common.GetAppImageName(appName, imageTag, "") if err := refreshAppJSON(appName, image); err != nil { return err } diff --git a/plugins/common/functions b/plugins/common/functions index 8191c2773..dfad49333 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -665,7 +665,7 @@ release_and_deploy() { source "$PLUGIN_AVAILABLE_PATH/config/functions" local APP="$1" - local IMAGE_TAG="$2" + local IMAGE_TAG="${2:-latest}" local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG") local DOKKU_DOCKERFILE_PORTS @@ -687,6 +687,7 @@ release_and_deploy() { local DOKKU_SKIP_DEPLOY=${DOKKU_APP_SKIP_DEPLOY:="$DOKKU_GLOBAL_SKIP_DEPLOY"} dokku_log_info1 "Releasing $APP..." + plugn trigger pre-deploy "$APP" "$IMAGE_TAG" dokku_release "$APP" "$IMAGE_SOURCE_TYPE" "$IMAGE_TAG" if [[ "$DOKKU_SKIP_DEPLOY" != "true" ]]; then diff --git a/plugins/config/docker-args-deploy b/plugins/config/docker-args-deploy index c429e3a83..2f4008227 100755 --- a/plugins/config/docker-args-deploy +++ b/plugins/config/docker-args-deploy @@ -10,7 +10,7 @@ trigger-config-docker-args() { declare APP="$1" IMAGE_TAG="$2" local ENV_ARGS IMAGE STDIN trigger - IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") + IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG") STDIN=$(cat) trigger="$0 config_docker_args" diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 4723ee9af..646c127be 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -224,10 +224,7 @@ func TriggerPostStop(appName string) error { // TriggerPreDeploy ensures an app has an up to date scale parameters func TriggerPreDeploy(appName string, imageTag string) error { - image, err := common.GetDeployingAppImageName(appName, imageTag, "") - if err != nil { - return err - } + image := common.GetAppImageName(appName, imageTag, "") if err := removeProcfile(appName); err != nil { return err diff --git a/plugins/scheduler-docker-local/pre-deploy b/plugins/scheduler-docker-local/pre-deploy index 3336bc627..dbd480362 100755 --- a/plugins/scheduler-docker-local/pre-deploy +++ b/plugins/scheduler-docker-local/pre-deploy @@ -65,7 +65,7 @@ scheduler-docker-local-pre-deploy-chown-app() { scheduler-docker-local-pre-deploy-precheck() { declare desc="Outputs the checks messages if necessary" declare APP="$1" IMAGE_TAG="$2" - local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") + local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG") local CHECKS_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX") trap "rm -rf '$CHECKS_FILE' >/dev/null" RETURN INT TERM EXIT copy_from_image "$IMAGE" "CHECKS" "$CHECKS_FILE" 2>/dev/null || true diff --git a/plugins/scheduler-docker-local/scheduler-deploy b/plugins/scheduler-docker-local/scheduler-deploy index ab3a1c281..3605794a6 100755 --- a/plugins/scheduler-docker-local/scheduler-deploy +++ b/plugins/scheduler-docker-local/scheduler-deploy @@ -22,7 +22,6 @@ trigger-scheduler-docker-local-scheduler-deploy() { DOKKU_HEROKUISH=false DOKKU_CNB=false IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG") - plugn trigger pre-deploy "$APP" "$IMAGE_TAG" is_image_cnb_based "$IMAGE" && DOKKU_CNB=true is_image_herokuish_based "$IMAGE" "$APP" && DOKKU_HEROKUISH=true