ansible-collections / ibm_zos_core

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

[Bug] {zos_job_submit] TypeError: submit() takes from 1 to 2 positional arguments but 3 were given #1465

Closed gngrossi closed 2 weeks ago

gngrossi commented 2 months ago

Is there an existing issue for this?

Bug description

Trying to use Python 3.12.1 on z/OS 2.5. Python 3.11.5 works.

IBM z/OS Ansible core Version

v1.9.0

IBM Z Open Automation Utilities

v1.2.5 (default)

IBM Enterprise Python

v3.12.x

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

zos_job_submit

Playbook verbosity output.

bash-4.4$ ansible-playbook submit.yml

PLAY [MA1] *****

TASK [Submit a job] **** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: submit() takes from 1 to 2 positional arguments but 3 were given fatal: [mvs-sysd]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"\", line 107, in \n File \"\", line 99, in _ansiballz_main\n File \"\", line 47, in invoke_module\n File \"\", line 226, in run_module\n File \"\", line 98, in _run_module_code\n File \"\", line 88, in _run_code\n File \"/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_781lrow0/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py\", line 1108, in \n File \"/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_781lrow0/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py\", line 1104, in main\n File \"/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_781lrow0/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py\", line 921, in run_module\n File \"/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_781lrow0/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py\", line 707, in submit_src_jcl\nTypeError: submit() takes from 1 to 2 positional arguments but 3 were given\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ***** mvs-sysd : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Ansible configuration.

bash-4.4$ ansible-config view
[defaults]
forks = 25
inventory = ~/playbooks/inventory.yml
host_key_checking = false
remote_port = 2222
timeout = 15
#deprecation_warnings=false

[ssh_connection]
pipelining = true

Contents of the inventory

#
# Hosts
#
MA1:
  hosts:
    mvs-sysd:
  vars:
    ansible_user: "@02858"
#

Contents of group_vars or host_vars

#
ZOAU_HOME:        /hewitt/zopentools/zoau1258
#ZOAU_HOME:        /hewitt/zopentools/zoau1310
#PYZ_HOME:         /hewitt/zopentools/python311/usr/lpp/IBM/cyp/v3r11/pyz
PYZ_HOME:         /hewitt/zopentools/python312/usr/lpp/IBM/cyp/v3r12/pyz

ansible_python_interpreter: "{{PYZ_HOME}}/bin/python3"

environment_vars:
  LIBPATH:        "{{ZOAU_HOME}}/lib:{{PYZ_HOME}}/lib:/lib:/usr/lib:."
  PATH:           "{{ZOAU_HOME}}/bin:{{PYZ_HOME}}/bin:/bin:/usr/sbin:."

  PYTHONSTDINENCODING: cp1047

# not compatible with pip installing the zoau package
# PYTHONPATH:     "{{ZOAU_HOME}}/lib"

# works without it
# LANG: C

  _BPXK_AUTOCVT:  ON
  _CEE_RUNOPTS:   "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
  _TAG_REDIR_IN:  txt
  _TAG_REDIR_OUT: txt
  _TAG_REDIR_ERR: txt
#
richp405 commented 2 months ago

I'm trying to see what's different here, because I haven't duplicated the error.

I'll check source code on our side for clarity

richp405 commented 2 months ago

zos_job_submit, line 699: job_submitted = jobs.submit(src, is_unix=is_unix, **kwargs)

I don't see anything version specific here, but it is passing potentially 3 arguments.

Right now, there are 2 possible issues that I can see:

  1. There could be a zoau 1.2.5.x issue with Python 3.12, since 3.11 works
  2. There could be a ansible-core issue with zoau < 1.3.1 issue in ansible, but that wouldn't explain why 3.11 works
richp405 commented 2 months ago

update: looking at other recent tickets, he is stating Ansible core 1.9, so I'll pull a copy of that for a deeper duplication, and a check of the line number.

richp405 commented 2 months ago

In 1.9.0 and 1,.9.1 source, the line I commented on above is exactly at 707. I'll check with zoau team to see if this rings a bell, because we are consistently passing 3 parameters.

gngrossi commented 2 months ago

Just to confirm: ansible [core 2.16.6] ibm.ibm_zos_core 1.9.0

The issue applies to z/OS 2.5 and 3.1

thanks

gngrossi commented 2 months ago

Trying the zos_data_set module:

TASK [Delete and define LDS] *** fatal: [mvs-sysd]: FAILED! => {"changed": false, "message": "", "msg": "TypeError(\"_create() missing 1 required positional argument: 'dataset_type'\")", "names": ["@02858.LDS"]}

richp405 commented 2 months ago

I'm seeing an issue in python 3.12 documentation (https://peps.python.org/pep-0692/), which means the way ibm_zos_core passes 'kwargs' might be at issue here. I'll run some tests in the next day or so to see if I can duplicate this and correct it.

Unfortunately, the current answer would be "this combination doesn't work with Python 3.12... use 3.11 until we understand what's going on better".

gngrossi commented 2 months ago

Ok thanks. My understanding is/was zoau 1.2.x.x worked with python 3.11.x and 3.12.x. And zoau1.3.x.x works with python 3.12.x but is waiting on ibm.ibm_zos_core 1.10.x

richp405 commented 2 months ago

I believe there is a combination of zos _core1.9.x + zoau 1.2 and 3.12 that causes this. I should duplicate this tonight, but because of the 3.12 pep change, I think you will need to wait for 1.10, so you can use zoau 1.3.x, which doesn't have this issue.

richp405 commented 1 month ago

I tried that exact combination: zoau 1.2.5 (tried .6 and .8), and got this on our official 1.9 test pipeline:

File : "/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_1u359rpg/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py", line 908, in run_module

File: "/tmp/ansible_ibm.ibm_zos_core.zos_job_submit_payload_1u359rpg/ansible_ibm.ibm_zos_core.zos_job_submit_payload.zip/ansible_collections/ibm/ibm_zos_core/plugins/modules/zos_job_submit.py", line 694, in submit_src_jcl

TypeError: submit() takes from 1 to 2 positional arguments but 3 were given. This is a coflict betweem zoau and python 3.12: using 3.11, as you have seen, works okay. I will relay this to the zoau team, to see if they have a work-around.

richp405 commented 1 month ago

Will make a python recreate to make sure zoau can duplicate this.

richp405 commented 1 month ago

@gngrossi : I'm getting odd responses using 1.2.4 versus 1.2.5.8, so I'm beginning to believe something was 'fixed' in 1.2.5.8, compared to earlier versions. This was done at the USS/console level. I'll try 2 other versions, then go to python duplication, but patching up to 1.2.5.8 may resolve this.

richp405 commented 1 month ago

I am not able to duplicate that specific error message using 1.2.3, 1.2.4, 1.2.5.6, or 1.2.5.8 with python 3.12. I even ported our core code to isolate the call even further, but no luck. My first suggestion will be to re-install 1.2.5.8, in case something was damaged from switching between 1.3.x and 1.2.x

I note you have PYTHONPATH commented out in the environment... could you try this with that value set, as well? I'm not aware of any compatibility issue there, but I don't use pip installs... our zoau versions are on a read-only volume in the testing area.

gngrossi commented 1 month ago

I have now migrated to using zos_core:==1.10.0-beta.1, zoau 1.3.1.1 with python 3.12.1 on z/OS 3.1.

richp405 commented 2 weeks ago

@gngrossi Following up: since you upgraded zos_core and zoau modules, are you satisfied so we can close this ticket?

gngrossi commented 2 weeks ago

Yes, closing. thanks