Properly handle non-deployed applications during apps:rename

An application which has not been deployed will not have an image
available, and therefore attempting to remove an (empty) cache directory
will fail. Rather than checking for the image - which we should
still do, as not having an image for a deployed app is an error state -
we should instead only attempt the docker cache removal if the directory
cannot be removed via rmdir.

Closes #2294
This commit is contained in:
Jose Diaz-Gonzalez
2016-07-29 00:07:34 -04:00
parent 85bdeaf47a
commit be3574136b
2 changed files with 16 additions and 1 deletions

View File

@@ -13,7 +13,9 @@ apps_rename_cmd() {
local NEW_APP="$3"
mkdir -p "$DOKKU_ROOT/$NEW_APP"
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$DOKKU_ROOT/$OLD_APP/cache:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
if ! rmdir "$DOKKU_ROOT/$OLD_APP/cache" > /dev/null 2>&1; then
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$DOKKU_ROOT/$OLD_APP/cache:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
fi
rm -rf "$DOKKU_ROOT/$OLD_APP/cache"
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"

View File

@@ -68,4 +68,17 @@ load test_helper
echo "output: "$output
echo "status: "$status
assert_success
run dokku apps:create $TEST_APP
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku apps:rename $TEST_APP great-test-name"
echo "output: "$output
echo "status: "$status
assert_output $TEST_APP
run bash -c "dokku --force apps:destroy great-test-name"
echo "output: "$output
echo "status: "$status
assert_success
}