From f1d36a212611efacc1d3f98b63ecbcc79e48acec Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 25 Jan 2018 20:43:16 +0100 Subject: [PATCH] syscontainers: allow the container name to end in .[01] We skipped file names just based on their ending without checking if it is a symlink. This prevented container with a name ending in .0 or .1 to be uninstalled. Signed-off-by: Giuseppe Scrivano Closes: #1166 Approved by: peterbaouoft --- Atomic/syscontainers.py | 7 ++++- .../test_system_containers_install.sh | 26 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Atomic/syscontainers.py b/Atomic/syscontainers.py index 6b1e3c8..e3e71a2 100644 --- a/Atomic/syscontainers.py +++ b/Atomic/syscontainers.py @@ -1462,7 +1462,12 @@ Warning: You may want to modify `%s` before starting the service""" % os.path.jo if not os.path.exists(fullpath): continue if fullpath.endswith(".0") or fullpath.endswith(".1"): - continue + # Skip the deployments if we have a symlink named in + # the same name except the ".[01]" ending. + # We avoid duplicates as we are already including the container + # in the results from the symlink and not from the deployments. + if os.path.islink(fullpath[:-2]): + continue with open(os.path.join(fullpath, "info"), "r") as info_file: info = json.load(info_file) diff --git a/tests/integration/test_system_containers_install.sh b/tests/integration/test_system_containers_install.sh index 840b023..003ccc3 100755 --- a/tests/integration/test_system_containers_install.sh +++ b/tests/integration/test_system_containers_install.sh @@ -13,6 +13,7 @@ IFS=$'\n\t' # 6. install from a dockertar # 7. install from local docker # 8. install a run-once system container +# 9. install a container with .0 in the name setup () { docker save atomic-test-system > ${WORK_DIR}/atomic-test-system.tar @@ -108,7 +109,7 @@ assert_matches ${SECRET}-new ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0/config.jso teardown -# 5. installing from a dockertar +# 6. installing from a dockertar export NAME="test-dockertar-system-container-$$" ${ATOMIC} install --name=${NAME} --set=RECEIVER=${SECRET} --system dockertar:/${WORK_DIR}/atomic-test-system.tar test -e /etc/tmpfiles.d/${NAME}.conf @@ -119,7 +120,7 @@ test -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0/tmpfiles-${NAME}.conf teardown -# 6. install from local docker +# 7. install from local docker export NAME="test-docker-system-container-$$" ${ATOMIC} install --name=${NAME} --set=RECEIVER=${SECRET} --system docker:atomic-test-system:latest test -e /etc/tmpfiles.d/${NAME}.conf @@ -130,13 +131,26 @@ test -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0/tmpfiles-${NAME}.conf teardown -# 7. install a run-once container +# 8. install a run-once container -export NAME="atomic-test-runonce" -${ATOMIC} pull --storage ostree docker:${NAME}:latest -${ATOMIC} install --system --name=Saturn --set RECEIVER=Pluto ${NAME}:latest > ${WORK_DIR}/ps.out +export NAME="Saturn" +${ATOMIC} pull --storage ostree docker:atomic-test-runonce:latest +${ATOMIC} install --system --name=${NAME} --set RECEIVER=Pluto atomic-test-runonce:latest > ${WORK_DIR}/ps.out assert_matches "HI Pluto from Saturn" ${WORK_DIR}/ps.out test \! -e /etc/systemd/system/${NAME}.service test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME} test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0 + +teardown + +# 9. install and uninstall a container with a name ending in .0 + +export NAME="container.0" +${ATOMIC} pull --storage ostree docker:atomic-test-system:latest +${ATOMIC} install --system --name=${NAME} atomic-test-system:latest +${ATOMIC} uninstall ${NAME} + +test \! -e /etc/systemd/system/${NAME}.service +test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME} +test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0