[PR #11837/87ecfa34 backport][stable-12] iso_extract: retry umount on busy filesystem before cleanup (#11857)

iso_extract: retry umount on busy filesystem before cleanup (#11837)

* iso_extract: retry umount on busy filesystem before cleanup

Fixes #5333



* iso_extract: add changelog fragment for #11837



* make chglog more concise

---------


(cherry picked from commit 87ecfa3432)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
patchback[bot]
2026-04-17 18:32:27 +02:00
committed by GitHub
parent 7b82e694a2
commit 956fc075ef
2 changed files with 13 additions and 1 deletions

View File

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

View File

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