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

Eliminate apparent state churn with resource pool computed attributes #927

Merged

Conversation

chrismarget-j
Copy link
Collaborator

@chrismarget-j chrismarget-j commented Oct 18, 2024

This PR eliminates apparent state churn related to always-null computed values in pool resources.

Consider a simple pool name change:

Before:

  # apstra_vni_pool.x will be updated in-place
  ~ resource "apstra_vni_pool" "x" {
        id              = "686e9c0b-e084-4e9a-9498-f9efa698969b"
      ~ name            = "bar" -> "foo"
      ~ ranges          = [
          - {
              - first = 5001 -> null
              - last  = 5010 -> null
            },
          + {
              + first           = 5001
              + last            = 5010
              + status          = (known after apply)
              + total           = (known after apply)
              + used            = (known after apply)
              + used_percentage = (known after apply)
            },
        ]
      + status          = (known after apply)
      + total           = (known after apply)
      + used            = (known after apply)
      + used_percentage = (known after apply)
    }

Note that most of the output is computed values which are going to be null anyway (#737, #752).

After:

  # apstra_vni_pool.x will be updated in-place
  ~ resource "apstra_vni_pool" "x" {
        id     = "686e9c0b-e084-4e9a-9498-f9efa698969b"
      ~ name   = "bar" -> "foo"
        # (1 unchanged attribute hidden)
    }

In this PR we have:

  • introduction of a new plan modifier UseNullStateForUnknown which works like the framework's UseStateForUnknown, but it doesn't ignore null values found in the state -- these also get replicated to the plan.
  • use of the new plan modifier on all of the pool metadata fields
  • normalization of the MarkdownDescription inline documentation for these un-readable metadata fields

Tested with:

  • 4.2.0
  • 4.2.1
  • 4.2.1.1
  • 4.2.2
  • 5.0.0

Closes #923

@chrismarget-j chrismarget-j linked an issue Oct 18, 2024 that may be closed by this pull request
@chrismarget-j chrismarget-j marked this pull request as draft October 18, 2024 04:08
@chrismarget-j chrismarget-j marked this pull request as ready for review October 18, 2024 17:57
@chrismarget-j chrismarget-j changed the title WIP: Reduce apparent state churn with resource pool computed attributes Reduce apparent state churn with resource pool computed attributes Oct 18, 2024
@chrismarget-j chrismarget-j changed the title Reduce apparent state churn with resource pool computed attributes Eliminate apparent state churn with resource pool computed attributes Oct 18, 2024
@chrismarget-j chrismarget-j merged commit 8f6d687 into main Oct 18, 2024
1 check passed
@chrismarget-j chrismarget-j deleted the 923-check-behavior-of-ipv4_pool-resource-when-renaming branch October 18, 2024 23:16
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.

Check behavior of ipv4_pool resource when renaming
2 participants