cdot65 / pan-os-upgrade

An efficient tool to execute configuration backups, network state snapshots, system readiness checks, and operating system upgrades of Palo Alto Networks firewalls and Panorama appliances.
https://cdot65.github.io/pan-os-upgrade/
Apache License 2.0
39 stars 7 forks source link

Implement auto-commit status check and handling during upgrade process #125

Open cdot65 opened 4 months ago

cdot65 commented 4 months ago

Is your feature request related to a problem? Please describe. During the upgrade process of a PAN-OS firewall using the pan-os-upgrade utility, there might be situations where the upgraded firewall is undergoing an auto-commit operation. If the utility proceeds with further actions while an auto-commit is in progress, it can lead to unexpected behavior or conflicts. Currently, the utility does not have a mechanism to detect and handle auto-commit scenarios, which can result in upgrade failures or inconsistencies.

Describe the solution you'd like Enhance the pan-os-upgrade utility to include a check for auto-commit status on the upgraded firewall and implement appropriate handling mechanisms. The utility should:

  1. After upgrading a firewall, check the status of the firewall to determine if an auto-commit operation is currently in progress.
  2. If an auto-commit is detected, the utility should pause the upgrade process and wait for a configurable amount of time (e.g., one minute) before checking the status again.
  3. Implement a maximum number of attempts (e.g., ten) to check for the auto-commit status. If the auto-commit is still ongoing after the maximum number of attempts, consider the upgrade as failed for that particular firewall.
  4. In case of a failure due to prolonged auto-commit, the utility should gracefully handle the situation by reporting the failure status and removing the peer firewall (if applicable) from the upgrade process.
  5. If no auto-commit is detected or if the auto-commit completes within the specified number of attempts, proceed with the normal upgrade flow.

Describe alternatives you've considered An alternative approach could be to forcefully terminate the auto-commit operation on the upgraded firewall to allow the upgrade process to continue. However, this might lead to unexpected consequences and could potentially leave the firewall in an inconsistent state. It is safer to wait for the auto-commit to complete naturally and handle the situation gracefully if it exceeds a reasonable timeframe.

Additional context Here are a few additional points to consider:

By implementing this feature, the pan-os-upgrade utility will be more resilient to auto-commit operations occurring during the upgrade process. It will prevent conflicts and ensure a smoother upgrade experience, while also handling failure scenarios gracefully.