Chad Smith has proposed merging ~chad.smith/cloud-init:bug/1795508-clean-no-trace-if-cwd-gets-deleted into cloud-init:master.
Commit message: clean: cloud-init clean should not trace when run from within cloud_dir Avoid traceback even if run from within /var/lib/cloud/* dirs which cloud-init clean deletes. LP: #1795508 Requested reviews: cloud-init commiters (cloud-init-dev) Related bugs: Bug #1795508 in cloud-init: "cloud-init clean from within /var/lib/cloud-init/instance" https://bugs.launchpad.net/cloud-init/+bug/1795508 For more details, see: https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/362229 -- Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:bug/1795508-clean-no-trace-if-cwd-gets-deleted into cloud-init:master.
diff --git a/cloudinit/cmd/clean.py b/cloudinit/cmd/clean.py index de22f7f..e9f12cf 100644 --- a/cloudinit/cmd/clean.py +++ b/cloudinit/cmd/clean.py @@ -10,7 +10,7 @@ import sys from cloudinit.stages import Init from cloudinit.util import ( - ProcessExecutionError, chdir, del_dir, del_file, get_config_logfiles, + ProcessExecutionError, del_dir, del_file, get_config_logfiles, is_link, subp) @@ -61,18 +61,18 @@ def remove_artifacts(remove_logs, remove_seed=False): if not os.path.isdir(init.paths.cloud_dir): return 0 # Artifacts dir already cleaned - with chdir(init.paths.cloud_dir): - for path in os.listdir('.'): - if path == 'seed' and not remove_seed: - continue - try: - if os.path.isdir(path) and not is_link(path): - del_dir(path) - else: - del_file(path) - except OSError as e: - error('Could not remove {0}: {1}'.format(path, str(e))) - return 1 + os.chdir(init.paths.cloud_dir): + for path in os.listdir('.'): + if path == 'seed' and not remove_seed: + continue + try: + if os.path.isdir(path) and not is_link(path): + del_dir(path) + else: + del_file(path) + except OSError as e: + error('Could not remove {0}: {1}'.format(path, str(e))) + return 1 return 0
_______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp