Closed KB30497 closed 2 years ago
From debugs on the Fortimanager side, the issue is possibly Terraform creating a policy and then failing to send a GET for the policy to retrieve its config and put it into state.
For example when "policy-21" is the policy that Terraform gets hung up on, the policy gets created:
Request:
{ "client": "\/usr\/local\/apache2\/bin\/httpd:18522", "method": "add", "params": [{ "data": { "action": "accept", "dstaddr": ["all"], "dstintf": ["any"], "logtraffic": "all", "name": "policy-21", "policyid": 21, "schedule": "always", "service": ["ALL"], "srcaddr": ["all"], "srcintf": ["any"], "status": "enable"}, "url": "\/pm\/config\/adom\/<adom>\/pkg\/<package>\/firewall\/policy"}], "session": "...", "src": "...", "verbose": 1}
But there's no corresponding GET coming from Terraform.
Compared to a policy that was created and put into state correctly ("policy-9"):
Request:
{ "client": "\/usr\/local\/apache2\/bin\/httpd:17716", "method": "add", "params": [{ "data": { "action": "accept", "dstaddr": ["all"], "dstintf": ["any"], "logtraffic": "all", "name": "policy-9", "policyid": 9, "schedule": "always", "service": ["ALL"], "srcaddr": ["all"], "srcintf": ["any"], "status": "enable"}, "url": "\/pm\/config\/adom\/<adom>\/pkg\/<package>\/firewall\/policy"}], "session": "...", "src": "...", "verbose": 1}
Request:
{ "client": "\/usr\/local\/apache2\/bin\/httpd:17716", "method": "get", "params": [{ "data": null, "url": "\/pm\/config\/adom\/<adom>\/pkg\/<package>\/firewall\/policy\/9"}], "session": "...", "src": "...", "verbose": 1}
I don't know what the significance of 25 policies is but that seems to consistently be the number where this starts happening.
Hi @KB30497,
Thank you for raising this issue. Team are working on it now. We will get back to you once it's resolved.
Thanks, Xing
Hi @KB30497,
This issue has been fixed in the latest release of FortiManager Terraform provider v1.4.0. Please use the latest version of FortiManager Terraform provider and try it again.
Please let me know if you have any questions.
Thanks, Xing
Confirmed that I'm no longer seeing this behavior - I created a few hundred policies at once with no issues.
Thank you.
Issue
We're seeing a consistent issue while creating more than 24 policies in the same Terraform apply. Once the amount of policies being created is >=25, the apply will hang after creating the 24th policy and keep trying to create the rest of the policies indefinitely.
Sometimes the rules after #24 get created and sometimes they don't. It seems that the Fortimanager API stops responding and Terraform gets stuck waiting for a response, so even if the rules are created they don't get entered into Terraform state.
Terraform Version
Terraform v1.1.4 on windows_amd64 provider registry.terraform.io/fortinetdev/fortimanager v1.3.6
Fortimanager Version
FMG-VM64-GCP Firmware Version | v6.4.7-build2412 210902 (GA)
Affected Resource(s)
fortimanager_packages_firewall_policy fortimanager_packages_firewall_localinpolicy
Terraform Configuration Files
Apply Output (Abbreviated)
Debug Output (Abbreviated)