From 87ecfa34327091df623dd94825dbb5958ac04804 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Fri, 17 Apr 2026 18:49:26 +1200 Subject: [PATCH] iso_extract: retry umount on busy filesystem before cleanup (#11837) * iso_extract: retry umount on busy filesystem before cleanup Fixes #5333 Co-Authored-By: Claude Sonnet 4.6 * iso_extract: add changelog fragment for #11837 Co-Authored-By: Claude Sonnet 4.6 * make chglog more concise --------- Co-authored-by: Claude Sonnet 4.6 --- .../fragments/11837-iso-extract-umount-retry.yml | 4 ++++ plugins/modules/iso_extract.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/11837-iso-extract-umount-retry.yml diff --git a/changelogs/fragments/11837-iso-extract-umount-retry.yml b/changelogs/fragments/11837-iso-extract-umount-retry.yml new file mode 100644 index 0000000000..7768e9675f --- /dev/null +++ b/changelogs/fragments/11837-iso-extract-umount-retry.yml @@ -0,0 +1,4 @@ +bugfixes: + - iso_extract - retry ``umount`` up to 5 times preventing ``OSError`` on cleanup + (https://github.com/ansible-collections/community.general/issues/5333, + https://github.com/ansible-collections/community.general/pull/11837). diff --git a/plugins/modules/iso_extract.py b/plugins/modules/iso_extract.py index 42d483dbeb..d45c616237 100644 --- a/plugins/modules/iso_extract.py +++ b/plugins/modules/iso_extract.py @@ -93,6 +93,7 @@ RETURN = r""" import os.path import shutil import tempfile +import time from ansible.module_utils.basic import AnsibleModule @@ -219,7 +220,14 @@ def main(): result["changed"] = True finally: if not binary: - module.run_command([module.get_bin_path("umount"), tmp_dir]) + umount_cmd = [module.get_bin_path("umount"), tmp_dir] + for dummy in range(5): + rc, dummy, dummy = module.run_command(umount_cmd) + if rc == 0: + break + time.sleep(1) + else: + module.warn(f"Failed to unmount ISO image from '{tmp_dir}' after 5 attempts.") shutil.rmtree(tmp_dir)