Skip to content

panos_check module doesn't account for a failed job #533

Open
@round3d

Description

@round3d

Describe the bug

A job can be in a failed state and not have the status field that the panos_check module requires. This causes it to never return ready.

Expected behavior

It should count failed jobs the same as those that are done.

Current behavior

If there are jobs with type Failed-Job then the panos_check module times out waiting for ready.

Possible solution

Debugging shows a job that is a type of Failed-Job but it doesn't have a status element.
The check

<response status="success">
   <result>
      <job>
         <type>Failed-Job</type>
         <details>
            <line>job failed because of configd restart</line>
         </details>
         <warnings/>
      </job>
      <job>
         <tenq>2024/01/25 18:15:25</tenq>
         <tdeq>18:15:25</tdeq>
         <id>57</id>
         <user>taylorjohn</user>
         <type>Commit</type>
         <status>FIN</status>
         <queued>NO</queued>
         <stoppable>no</stoppable>
         <result>OK</result>
         <tfin>2024/01/25 18:17:09</tfin>
         <description/>
         <positionInQ>0</positionInQ>
         <progress>100</progress>
         <details>
            <line>Configuration committed successfully</line>
         </details>
         <warnings/>
      </job>

A fix could be to return True in check_jobs for job_type == "Failed-Job".

def check_jobs(jobs):
    if len(jobs) == 0:
        return False

    for j in jobs:
        job_type = j.findtext(".//type")
        job_result = j.findtext(".//result")

        if job_type == "Failed-Job":
            return True

        if job_type is None or job_result is None:
            return False

        if job_type == "AutoCom" and job_result == "OK":
            return True
        elif job_type == "AutoCom":
            return False

Your Environment

  • Python: Python 3.9.2
  • Ansible: ansible [core 2.15.8]
  • PAN-OS Python Library & version (e.g. pandevice 0.14.0, pan-os-python 1.0.2): pan-os-python 1.11.0 pan-python 0.17.0
  • device: PA-440 panos 10.1.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions