fortinetdev / terraform-provider-fortios

Terraform Fortios provider
https://www.terraform.io/docs/providers/fortios/
Mozilla Public License 2.0
69 stars 50 forks source link

Getting error -56: set timezone '' with terraform destroy #348

Closed rasanentimo closed 3 weeks ago

rasanentimo commented 1 month ago

Description

I created following resource

  "resource": {
    "fortios_system_global": {
      "global": {
        "vdom_mode": "multi-vdom",
        "timezone": "UTC",
        "hostname": "fw1",
        "lldp_transmission": "enable",
        "lldp_reception": "enable"
      }
    }
  }

but I'm getting error when trying to destroy it, i.e. terraform tries to set timezone empty string/'' which fails.

fortios_system_global.global: Destroying... [id=SystemGlobal]
╷
│ Error: Error clearing SystemGlobal resource: Internal Server Error - Internal error when processing the request (500)
│ Cli response: 
│ [vdom-mode cannot be disabled when multiple vdoms are present. path=system, objname=global, size=3320, sz_attr=1 value parse error before '' Command fail. Return code -56 cmd_clean_context 0, abort=1 cmd_clean_context 0, abort=1 Command fail. Return code 1]

The same can be seen on the debug

[httpsd 3330 - 1730147891     info] api_unset_cmdb_node[2477] -- 'auth-session-auto-backup-interval'
[httpsd 3330 - 1730147891     info] api_unset_cmdb_node[2477] -- 'scim-https-port'
[httpsd 3330 - 1730147891     info] api_unset_cmdb_node[2477] -- 'scim-http-port'
0: config global
0: config system global
0: set gui-auto-upgrade-setup-warning enable
-56: set timezone ''
(skipped) set hostname "FortiGate-VM64-KVM"

(skipped) set lldp-transmission disable

(skipped) set lldp-reception disable

(skipped) set vdom-mode no-vdom

[httpsd 3330 - 1730147891     info] cmdb_save_with_children[280] -- appended main node (nret=-56, is_new=0)
[httpsd 3330 - 1730147891    error] cmdb_save_with_children[285] -- saving failed for main node: 'global' (err=-56)

[httpsd 3330 - 1730147891    error] cmdb_commit_from_json[2332] -- error saving request object to CLI (-56)
[httpsd 3330 - 1730147891    error] _api_cmdb_v2_config[2354] -- error editing object (nret=-56)
[httpsd 3330 - 1730147891  warning] api_return_http_result[1270] -- API error -56 raised
fw1 (global) # set timezone ''

value parse error before ''
Command fail. Return code -56
MaxxLiu22 commented 1 month ago

Hi @rasanentimo ,

Thank you for bringing this issue to our attention. I was able to reproduce it, and it appears that the destroy fortios_system_global command attempts to reset all settings to their initial state, similar to the unset operation in the CLI. However, when unsetting the timezone, the CLI tries to leave it empty rather than its default value, which is not accepted by FortiOS. I've reported this to the IaC development team for careful handling. We appreciate your patience as we work on a resolution.

Thanks, Maxx

MaxxLiu22 commented 3 weeks ago

Hi @rasanentimo,

I'm pleased to let you know that we've released Terraform FOS 1.21.1, which should address the issue you've encountered. Please feel free to upgrade at your convenience, and don’t hesitate to reach out if you have any further questions or need assistance.

Thank you, Maxx

rasanentimo commented 3 weeks ago

Hi @MaxxLiu22 !

I can confirm that this works now as expected.