Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Prevent destroy operation for static ports in bulk list when… #271

Conversation

akinross
Copy link
Collaborator

… updating the list

fixes #270

Copy link
Collaborator

@shrsr shrsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@sajagana sajagana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@lhercot lhercot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lhercot lhercot merged commit fd8e194 into CiscoDevNet:master May 6, 2024
@edudppaz
Copy link

Hi @akinross . The issue itself seems to be fixed as now the resource is updated-in-place instead of destroyed-recreating. But adding a new port to the list now re-orders the list, showing an update to every single entry on the bulk. Im guessing this is due to some sort() or ordering of the data when being written to the state.
It technically doesnt affect the resource being applied, but it would be nice to get the "real" change instead of a re-ordering of all paths:

  # module.tf-aci-ndo-staticports.mso_schema_site_anp_epg_bulk_staticport.accessPortsL2_bulk["TENANT-server-03-EPG-ACI"] will be updated in-place
  ~ resource "mso_schema_site_anp_epg_bulk_staticport" "accessPortsL2_bulk" {
        id            = "/site//template/Strchd-L2-Template/anp/server-AP/epg/server-03-EPG"
        # (5 unchanged attributes hidden)

      ~ static_ports {
          ~ path                 = "eth1/3" -> "eth1/20"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/4" -> "eth1/3"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/5" -> "eth1/4"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/6" -> "eth1/5"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/7" -> "eth1/6"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/8" -> "eth1/7"
            # (8 unchanged attributes hidden)
        }
      ~ static_ports {
          ~ path                 = "eth1/9" -> "eth1/8"
            # (8 unchanged attributes hidden)
        }
      + static_ports {
          + deployment_immediacy = "lazy"
          + leaf                 = "1001"
          + micro_seg_vlan       = 0
          + mode                 = "regular"
          + path                 = "eth1/9"
          + path_type            = "port"
          + pod                  = "pod-1"
          + vlan                 = 2002
        }

On this output, the new port in the configuration is the 1/20. The 1/9 is already configured, but due to the re-ordering on the state, is being shown as a new one.

@shrsr
Copy link
Collaborator

shrsr commented Aug 21, 2024

@edudppaz Akini is on leave and will be back soon!

The reason you are seeing this behaviour is because static_ports is defined as TypeList in the resource which makes Terraform treat static_ports as ordered collections. This means that the order of items in a list is significant and any change in the order of items is considered a change to the list itself.

A way to get around this would be to use TypeSet for the said attribute but it comes with its own cosmetic quirks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mso_schema_site_anp_epg_bulk_staticport resource destroys/recreates object instead of updating
6 participants