ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
77 stars 44 forks source link

[Bug]data_set_utils bad import #1529

Closed AndreMarcel99 closed 3 months ago

AndreMarcel99 commented 4 months ago

Is there an existing issue for this?

Bug description

data_set.py utils when try to create a dataset in the catch exception throw a unable to import exeption

        try:
            datasets.create(**formatted_args)
        except exceptions._ZOAUExtendableException as create_exception:
            raise DatasetCreateError(
                raw_name if raw_name else name,
                create_exception.response.rc,
                create_exception.response.stdout_response + "\n" + create_exception.response.stderr_response
            )
        except exceptions.DatasetVerificationError as e:
            # verification of a data set spanning multiple volumes is currently broken in ZOAU v.1.3.0
            if volumes and len(volumes) > 1:
                if DataSet.data_set_cataloged(name, volumes):
                    return 0
            raise DatasetCreateError(
                raw_name if raw_name else name,

IBM z/OS Ansible core Version

v1.10.0-beta.1

IBM Z Open Automation Utilities

v1.2.5 (default)

IBM Enterprise Python

v3.11.x (default)

ansible-version

v2.17.x

z/OS version

v2.5 (default)

Ansible module

zos_blockinfile

Playbook verbosity output.

No response

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

richp405 commented 3 months ago

Need to document for 1.10, fix in 1.11.b-1 We need to recreate this internally before assignment.

fernandofloresg commented 3 months ago

Original publisher was not able to reproduce this issue, which was catch after modifying the code, I tried to make the module fail just to see if those exceptions had any problem.

Used the following code:

---
- hosts: zvm
  collections:
    - ibm.ibm_zos_core
  gather_facts: false
  vars:
    ZOAU: "/zoau/v1.3.1"
    PYZ: "/allpython/3.11-3/usr/lpp/IBM/cyp/v3r11/pyz"

  environment: "{{ environment_vars }}"

  tasks:
    # Test role
    - name: sumit JCL in a role with loop
      zos_data_set:
        name: omvsadm.test.data
        state: present
        record_format: fba
        record_length: 20
        space_type: g
        space_primary: 1000
      register: result

    - name: debug
      debug:
        msg: "{{ result }}"

Got the following expected error :


The full traceback is:
  File "/tmp/ansible_zos_data_set_payload__qrrhapo/ansible_zos_data_set_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_data_set.py", line 1887, in run_module
  File "/tmp/ansible_zos_data_set_payload__qrrhapo/ansible_zos_data_set_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_data_set.py", line 1410, in perform_data_set_operations
  File "/tmp/ansible_zos_data_set_payload__qrrhapo/ansible_zos_data_set_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/module_utils/data_set.py", line 1976, in ensure_present
    rc = DataSet.ensure_present(**arguments)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/ansible_zos_data_set_payload__qrrhapo/ansible_zos_data_set_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/module_utils/data_set.py", line 182, in ensure_present
    DataSet.create(**arguments)
  File "/tmp/ansible_zos_data_set_payload__qrrhapo/ansible_zos_data_set_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/module_utils/data_set.py", line 1035, in create
    raise DatasetCreateError(
fatal: [zvm]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "batch": null,
            "block_size": null,
            "directory_blocks": null,
            "empty": null,
            "extended": null,
            "fifo": null,
            "force": false,
            "key_length": null,
            "key_offset": null,
            "limit": null,
            "name": "omvsadm.test.data",
            "purge": null,
            "record_format": "fba",
            "record_length": 20,
            "replace": false,
            "scratch": null,
            "sms_data_class": null,
            "sms_management_class": null,
            "sms_storage_class": null,
            "space_primary": 1000,
            "space_secondary": 3,
            "space_type": "g",
            "state": "present",
            "tmp_hlq": null,
            "type": "pds",
            "volumes": null
        }
    },
    "message": "",
    "msg": "DatasetCreateError('An error occurred during creation of data set \"OMVSADM.TEST.DATA\". RC=4, {\"data\":{\"dsname\":\"OMVSADM.TEST.DATA\",\"dsorg\":\"PO\",\"recfm\":\"FBA\",\"dsntype\":\"PDS\",\"primary\":-12835,\"secondary\":-22852,\"lrecl\":20,\"blksize\":0,\"dirblks\":5},\"program\":\"dtouch\",\"options\":\"-j -t pds -s 1000g -e 3g -r fba -l 20 -j \",\"rc\":\"4\"}\\n\\nBGYSC1402E Dynalloc Failure. Error Code: 0x970c, Information Code: 0x00\\n')",
    "names": [
        "OMVSADM.TEST.DATA"
    ]
}

So, looks like the exceptions are working correctly and not getting a bad import error.