F5Networks / f5-ansible

Imperative Ansible modules for F5 BIG-IP products
GNU General Public License v3.0
375 stars 229 forks source link

bigip_provision: infinite loops when provisioning modules #2313

Closed simonkowallik closed 1 year ago

simonkowallik commented 1 year ago
COMPONENT NAME

bigip_provision version 1.22.1

Environment

ANSIBLE VERSION
2.14.2, python 3.9.13
BIGIP VERSION
16.1.3.3
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

The ansible task using bigip_provision hangs forever when the issue occurs. The source of this issue seem to be multiple but none of them seem to occur all the time in all use-cases of bigip_provision.

It seems to depend on either the number of modules which need to be provisioned, the specific module to provision and/or race condition(s).

Ultimately bigip_provision runs into an infinite loop, which seems to be caused by the logic within bigip_provision and the frequent code that ignores any exceptions ("except Exception: pass").

STEPS TO REPRODUCE

Loop through modules ["asm", "avr", "afm"] and executing bigip_provision sequentially.

EXPECTED RESULTS

Modules get provisioned as expected and the playbook continues

ACTUAL RESULTS

The playbook hangs during execution of the task till it gets stopped by an ansible execution timeout or stopped manually (after hours...)

simonkowallik commented 1 year ago

2286 is related.

The (error handling) logic within the bigip_provision module provides a lot of room for race conditions and infinite loops.

If an exception is raised on the previous try block, the below code will possibly lead to an infinite loop unless the if condition is true. https://github.com/F5Networks/f5-ansible/blob/756276916fec21dc74c071edf698657fe74b3ce0/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_provision.py#L410-L413

With an exception raised in the try block, this leads to an infinite loop:

AFM (_wait_for_afm_ready): https://github.com/F5Networks/f5-ansible/blob/756276916fec21dc74c071edf698657fe74b3ce0/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_provision.py#L945-L946

CGNAT (_wait_for_cgnat_ready): https://github.com/F5Networks/f5-ansible/blob/756276916fec21dc74c071edf698657fe74b3ce0/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_provision.py#L981-L982

MGMT (_wait_for_mgmt_ready): https://github.com/F5Networks/f5-ansible/blob/756276916fec21dc74c071edf698657fe74b3ce0/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_provision.py#L1017-L1018

These are just a few examples.

pgouband commented 1 year ago

Hi, thanks for reporting this issue. Added to the backlog and internal tracking ID for this request is: INFRAANO-1167, thanks!