CiscoDevNet / terraform-provider-iosxr

Terraform Cisco IOS-XR Provider
https://registry.terraform.io/providers/CiscoDevNet/iosxr
Mozilla Public License 2.0
6 stars 9 forks source link

bug: iosxr_router_bgp_vrf "neighbors" always bring a change when using dot notation with trailing zero #263

Closed edudppaz closed 1 month ago

edudppaz commented 1 month ago

When using a dot notation for the ASN for bgp neighbors, and the ASN has trailing zeros , for example: 65500.100 the value gets properly pushed to the devices, but gets stored in the state as 65500.1, so on each plan, terraform brings a change to the value:

  # iosxr_router_bgp_vrf.fusion_bgp_vrf_inside["fn01"] will be updated in-place
  ~ resource "iosxr_router_bgp_vrf" "fusion_bgp_vrf_inside" {
        id                            = "Cisco-IOS-XR-um-router-bgp-cfg:/router/bgp/as[as-number=64599]/vrfs/vrf[vrf-name=abc]"
      ~ neighbors                     = [
          ~ {
              ~ remote_as                 = "64597.1" -> "64597.100"
                # (5 unchanged attributes hidden)
            },
        ]
        # (4 unchanged attributes hidden)
    }

It seems like the value is being saved as floating point or int on the state, it should be saved as a string to allow trailing zeros.

kuba-mazurkiewicz commented 1 month ago

Can you enable debugging and paste content of GET response ?

danischm commented 1 month ago

https://github.com/CiscoDevNet/terraform-provider-iosxr/commit/d1282fe70b6be203cfb8b05712993e9392813142

danischm commented 1 month ago

Be aware that this is a bug in the XR YANG/gNMI implementation as the value is returned as a JSON number (without quotes) and therefore correctly interpreted as a floating point number. I would recommend to open a case with Cisco to get this fixed. For now we have implemented a workaround on the provider side to always interpret the AS number as a string.

danischm commented 1 month ago

Workaround implemented in 0.5.2 release.