1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-05 18:45:01 +01:00

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 <gscrivan@redhat.com>

Closes: #1166
Approved by: peterbaouoft
This commit is contained in:
Giuseppe Scrivano
2018-01-25 20:43:16 +01:00
committed by Atomic Bot
parent 6e55cc8e6b
commit f1d36a2126
2 changed files with 26 additions and 7 deletions

View File

@@ -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)

View File

@@ -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