Skip to content
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

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

Open
round3d opened this issue Jan 26, 2024 · 0 comments · May be fixed by #539
Open

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

round3d opened this issue Jan 26, 2024 · 0 comments · May be fixed by #539
Labels
bug Something isn't working

Comments

@round3d
Copy link

round3d commented Jan 26, 2024

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
@round3d round3d added the bug Something isn't working label Jan 26, 2024
@round3d round3d linked a pull request Feb 8, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant