Skip to content

Adding error suggestion to generic error while copying GDG if its in edit mode. #2220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 11, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
minor_changes:
- zos_copy - Adds a better error message that gives user a
hint that copy issue can be due to a GDS part of ``src`` GDG is
being used by another process.
(https://github.com/ansible-collections/ibm_zos_core/pull/2220)
27 changes: 24 additions & 3 deletions plugins/modules/zos_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,23 @@ def copy_to_gdg(self, src, dest):
# If identical_gdg_copy is False, use the default next generation
dest_gen_name = f"{dest}(+1)"
# Perform the copy operation
rc = datasets.copy(gds.name, dest_gen_name, **copy_args)
if rc != 0:
success = False

try:
result = datasets.copy(gds.name, dest_gen_name, **copy_args)
rc = result.rc if hasattr(result, 'rc') else result
if rc != 0:
success = False
except zoau_exceptions.ZOAUException as e:
stderr = getattr(e.response, 'stderr_response', str(e))
if "BGYSC0514E" in stderr :
raise GenerationDataGroupCreateError(
msg=(
"BGYSC0514E An error occurred while attempting to define the file."
" This might be because the GDS part of the src GDG is being used by another process."
)
) from e
else:
raise GenerationDataGroupCreateError(msg=f"GDG creation failed. Raw error: {stderr}") from e
return success

def _copy_tree(self, entries, src, dest, dirs_exist_ok=False):
Expand Down Expand Up @@ -4343,5 +4357,12 @@ def __init__(
super().__init__(msg)


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


if __name__ == "__main__":
main()