mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-21 00:01:08 +00:00
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:
4
changelogs/fragments/11837-iso-extract-umount-retry.yml
Normal file
4
changelogs/fragments/11837-iso-extract-umount-retry.yml
Normal 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).
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user