Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/2255-data_set-Enhance-error-message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- zos_data_set - Enhances error messages when deleting a Generation Data Group fails.
(https://github.com/ansible-collections/ibm_zos_core/pull/2255)
37 changes: 30 additions & 7 deletions plugins/module_utils/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3051,13 +3051,29 @@ def ensure_absent(self, force):
rc = datasets.delete(self.name)
if rc > 0:
if force:
if isinstance(self.gdg, gdgs.GenerationDataGroupView):
self.gdg.delete()
else:
gdg_view = gdgs.GenerationDataGroupView(name=self.name)
gdg_view.delete()
else:
raise DatasetDeleteError(self.raw_name, rc)
try:
if isinstance(self.gdg, gdgs.GenerationDataGroupView):
self.gdg.delete()
else:
gdg_view = gdgs.GenerationDataGroupView(name=self.name)
gdg_view.delete()
except exceptions._ZOAUExtendableException as e:
stderr = getattr(e.response, 'stderr_response', '')
if "BGYSC1603I" in stderr:
raise GenerationDataGroupDeleteError(
msg=(
"Data set deletion failed: the generation data set is currently in use "
" by another job or session. Try deleting after ensuring no active usage."
)
)
elif "BGYSC5906E" in stderr:
raise GenerationDataGroupDeleteError(
msg="GDG deletion failed due to an IDCAMS failure. A GDS might be in use or locked."
)
else:
raise GenerationDataGroupDeleteError(
msg=f"GDG deletion failed. Raw error: {stderr}"
)
else:
return False
return True
Expand Down Expand Up @@ -3505,3 +3521,10 @@ def __init__(self, msg):
"""Error during creation of a Generation Data Group."""
self.msg = msg
super().__init__(self.msg)


class GenerationDataGroupDeleteError(Exception):
def __init__(self, msg):
"""Error during deletion of a Generation Data Group."""
self.msg = msg
super().__init__(self.msg)