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 <noreply@anthropic.com>

* iso_extract: add changelog fragment for #11837

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* make chglog more concise

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky
2026-04-17 18:49:26 +12:00
committed by GitHub
parent e911081102
commit 87ecfa3432
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)