fix: always retire deployment task containers
Without this, the normal cleanup routine would not remove the containers, and removal would require a manual call to 'dokku cleanup'.
This commit is contained in:
1 parent
85b09e11cf
commit
8766820974
2 files changed
+17
-2
No files matched your search
@@ -154,6 +154,13 @@ func getDokkuAppShell(appName string) string {
|
|||||||
return shell
|
return shell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanupDeploymentContainer(appName string, containerID string, phase string) error {
|
||||||
|
if phase != "predeploy" {
|
||||||
|
os.Setenv("DOKKU_SKIP_IMAGE_RETIRE", "true")
|
||||||
|
}
|
||||||
|
return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...)
|
||||||
|
}
|
||||||
|
|
||||||
func executeScript(appName string, image string, imageTag string, phase string) error {
|
func executeScript(appName string, image string, imageTag string, phase string) error {
|
||||||
phaseName := phase
|
phaseName := phase
|
||||||
if phase == "heroku.postdeploy" {
|
if phase == "heroku.postdeploy" {
|
||||||
@@ -255,6 +262,8 @@ func executeScript(appName string, image string, imageTag string, phase string)
|
|||||||
return fmt.Errorf("Failed to create %s execution container: %s", phase, err.Error())
|
return fmt.Errorf("Failed to create %s execution container: %s", phase, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer cleanupDeploymentContainer(appName, containerID, phase)
|
||||||
|
|
||||||
if !waitForExecution(containerID) {
|
if !waitForExecution(containerID) {
|
||||||
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phaseName, containerID[0:9]))
|
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phaseName, containerID[0:9]))
|
||||||
common.LogVerboseQuietContainerLogs(containerID)
|
common.LogVerboseQuietContainerLogs(containerID)
|
||||||
@@ -302,7 +311,7 @@ func executeScript(appName string, image string, imageTag string, phase string)
|
|||||||
return fmt.Errorf("Commiting of '%s' to image failed: %s", phase, command)
|
return fmt.Errorf("Commiting of '%s' to image failed: %s", phase, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEntrypointFromImage(image string) (string, error) {
|
func getEntrypointFromImage(image string) (string, error) {
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ trigger-scheduler-docker-local-scheduler-register-retired() {
|
|||||||
declare APP="$1" CONTAINER_ID="$2" WAIT="${3:-60}"
|
declare APP="$1" CONTAINER_ID="$2" WAIT="${3:-60}"
|
||||||
local IMAGE_ID
|
local IMAGE_ID
|
||||||
|
|
||||||
IMAGE_ID="$("$DOCKER_BIN" container inspect "$CONTAINER_ID" --format "{{.Image}}" 2>/dev/null | cut -d: -f2 || true)"
|
if [[ -z "$CONTAINER_ID" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DOKKU_SKIP_IMAGE_RETIRE" != "true" ]]; then
|
||||||
|
IMAGE_ID="$("$DOCKER_BIN" container inspect "$CONTAINER_ID" --format "{{.Image}}" 2>/dev/null | cut -d: -f2 || true)"
|
||||||
|
fi
|
||||||
fn-scheduler-docker-local-register-retired "container" "$APP" "$CONTAINER_ID" "$WAIT"
|
fn-scheduler-docker-local-register-retired "container" "$APP" "$CONTAINER_ID" "$WAIT"
|
||||||
|
|
||||||
if [[ -n "$IMAGE_ID" ]]; then
|
if [[ -n "$IMAGE_ID" ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user