Skip to content

Commit

Permalink
syscontainers: do not leave broken symlink on uninstall
Browse files Browse the repository at this point in the history
Use `os.path.lexists' to verify its presence.  Delete the symlink before
the deployments, so that the container doesn't look installed while its
being deleted.

Closes: projectatomic#495

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: projectatomic#497
Approved by: jlebon
  • Loading branch information
giuseppe committed Jul 26, 2016
1 parent 1aed86f commit 2d3db1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,11 @@ def uninstall_system_container(self, name):
except subprocess.CalledProcessError:
pass

if os.path.lexists("%s/%s" % (self._get_system_checkout_path(), name)):
os.unlink("%s/%s" % (self._get_system_checkout_path(), name))
for deploy in ["0", "1"]:
if os.path.exists("%s/%s.%s" % (self._get_system_checkout_path(), name, deploy)):
shutil.rmtree("%s/%s.%s" % (self._get_system_checkout_path(), name, deploy))
if os.path.exists("%s/%s" % (self._get_system_checkout_path(), name)):
os.unlink("%s/%s" % (self._get_system_checkout_path(), name))

if os.path.exists(os.path.join(SYSTEMD_UNIT_FILES_DEST, "%s.service" % name)):
os.unlink(os.path.join(SYSTEMD_UNIT_FILES_DEST, "%s.service" % name))

Expand Down
3 changes: 3 additions & 0 deletions tests/integration/test_system_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ ${ATOMIC} umount ${WORK_DIR}/mount

${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
test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1

# check that there are not any "ociimage/" prefixed branch left after images prune
ostree --repo=${ATOMIC_OSTREE_REPO} refs --delete "ociimage/atomic-test-system-latest"
Expand Down

0 comments on commit 2d3db1c

Please sign in to comment.