Skip to content

[Bug] [zos_job_query] Module is passing * for job_id when the task specifies None leading to all jobs being queried. #2367

@ddimatos

Description

@ddimatos

Is there an existing issue for this?

  • There are no existing issues.

Bug description

Review the internal discussion here: <sanitized>/archives/CSLEJ8VGV/p1760138787897389?thread_ts=1754323020.810359&cid=CSLEJ8VGV

In zos_job_query, there is this logic my assumption is this might have been placed for when ZOAU did not handle wild cards but unsure.

Now that it does handle wild cards the interpretation of None to * is detrimental in that it causes the module to query all system jobs , ones that the current user does not have access to view causing RACF violations.

    jobs = []
    if job_id:
        jobs = job_status(job_id=job_id)
    elif owner:
        jobs = job_status(owner=owner, job_name=job_name)
    else:
        jobs = job_status(job_name=job_name)
    if not jobs:
        raise RuntimeError("List FAILED! no such job was found.")
    return jobs

While helping a user, I made a minor modification that completely removed the above block of code and from then on the user did not trigger the RACF violations , that change was to remove the above and replace it with (below) essentially overriding the existing logic and allowing for ZOAU talking to the SSI to handle the values passed from the module via ZOAU fetch_multiple.

jobs = []
jobs = job_status(job_id=job_id, owner=owner, job_name=job_name, dd_name=False)
return jobs

To prove this was happening, the second code edit was to force an exception to show me what ZOAU was receiving before my above code change, for that I added to ../module_utils/job.py

From:

    # expanding > 1.3.0 of zoau, to include all params
    entries = jobs.fetch_multiple(job_id=job_id_temp, job_owner=owner, include_extended=True)

To:

    mssg = f"fetch_multiple is passed job_id=[{job_id}], job_name=[{job_name}], owner=[{owner}]]."
    raise Exception(mssg)

Which yields for these module options below, noticed that None became --> * for job_id.

       "module_args": {
            "job_id": null,
            "job_name": "BG*",
            "owner": "IBMUSER"
        }
    },
    "message": "",
    "msg": "fetch_multiple is passed job_id=[*], job_name=[BG*], owner=[IBMUSER]]."

I believe the logic in the zos_job_query module needs to be reviewed and decided if it really is needed given ZOAU can handle all three options, maybe the right way is to pass all 3 options, job_id, job_name, owner all at once instead of this if/else logic in the zos_job_query module.

IBM z/OS Ansible core Version

v1.14.0

IBM Z Open Automation Utilities

v1.3.3

IBM Enterprise Python

v3.11.x

ansible-version

v2.15.x

z/OS version

v2.5

Metadata

Metadata

Labels

BugSomething isn't working as designed.Was triagedAn item that went through the triage process.

Type

No type

Projects

Status

⚙ Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions