feat: handle case where old, renamed containers may still be running during ps:restore
This commit is contained in:
@@ -9,6 +9,9 @@ ps_restore_cmd() {
|
|||||||
local cmd="ps:restore"
|
local cmd="ps:restore"
|
||||||
local APP="$2"
|
local APP="$2"
|
||||||
|
|
||||||
|
local DOKKU_SCHEDULER=$(config_get "$APP" DOKKU_SCHEDULER || echo "docker-local")
|
||||||
|
plugn trigger pre-restore "$DOKKU_SCHEDULER"
|
||||||
|
|
||||||
if [[ -n "$APP" ]]; then
|
if [[ -n "$APP" ]]; then
|
||||||
if ! (is_deployed "$APP"); then
|
if ! (is_deployed "$APP"); then
|
||||||
dokku_log_warn "App $APP has not been deployed"
|
dokku_log_warn "App $APP has not been deployed"
|
||||||
|
|||||||
19
plugins/scheduler-docker-local/pre-restore
Executable file
19
plugins/scheduler-docker-local/pre-restore
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
|
||||||
|
scheduler-docker-local-pre-restore() {
|
||||||
|
declare desc="scheduler-docker-local pre-restore plugin trigger"
|
||||||
|
declare trigger="scheduler-docker-local pre-restore"
|
||||||
|
declare DOKKU_SCHEDULER="$1"
|
||||||
|
|
||||||
|
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# delete all "old" containers
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
docker rm $(docker ps --format "{{.Names}}" -a -f "label=$DOKKU_CONTAINER_LABEL" -q | grep -E '(.+\..+\.[0-9]+\.[0-9]+$)') &> /dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduler-docker-local-pre-restore "$@"
|
||||||
Reference in New Issue
Block a user