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

Add diff suppression for hard limits on kubernetes_resource_quota #1251

Merged
merged 2 commits into from
May 13, 2021
Merged

Add diff suppression for hard limits on kubernetes_resource_quota #1251

merged 2 commits into from
May 13, 2021

Conversation

ecrousseau
Copy link
Contributor

@ecrousseau ecrousseau commented Apr 29, 2021

Description

Adds DiffSuppressFunc to resource kubernetes_resource_quota with the intention of preventing terraform plan from coming up with non-ops such as 1k -> 1000.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'
==> Checking that code complies with gofmt requirements...
go vet .
rm -rf /home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraform /home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraform.lock.hcl || true
mkdir /home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraform
mkdir -p /tmp/.terraform.d/localhost/test/kubernetes/9.9.9/linux_amd64 || true
ls /tmp/.terraform.d/localhost/test/kubernetes/9.9.9/linux_amd64/terraform-provider-kubernetes_9.9.9_linux_amd64 || go build -o /tmp/.terraform.d/localhost/test/kubernetes/9.9.9/linux_amd64/terraform-provider-kubernetes_9.9.9_linux_amd64
/tmp/.terraform.d/localhost/test/kubernetes/9.9.9/linux_amd64/terraform-provider-kubernetes_9.9.9_linux_amd64
cd /home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers && TF_CLI_CONFIG_FILE=/home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraformrc TF_PLUGIN_CACHE_DIR=/home/rous
seae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraform terraform init -upgrade

Initializing the backend...

Initializing provider plugins...
- Finding localhost/test/kubernetes versions matching "9.9.9"...
- Installing localhost/test/kubernetes v9.9.9...
- Installed localhost/test/kubernetes v9.9.9 (unauthenticated)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
TF_CLI_CONFIG_FILE=/home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraformrc TF_PLUGIN_CACHE_DIR=/home/rousseae/github/terraform-provider-kubernetes/kubernetes/test-infra/external-providers/.terraform TF_AC
C=1 go test "/home/rousseae/github/terraform-provider-kubernetes/kubernetes" -v -run=TestAccKubernetesResourceQuota -timeout 120m
=== RUN   TestAccKubernetesResourceQuota_basic
--- PASS: TestAccKubernetesResourceQuota_basic (12.80s)
=== RUN   TestAccKubernetesResourceQuota_generatedName
--- PASS: TestAccKubernetesResourceQuota_generatedName (3.74s)
=== RUN   TestAccKubernetesResourceQuota_withScopes
--- PASS: TestAccKubernetesResourceQuota_withScopes (7.08s)
PASS
ok  github.com/hashicorp/terraform-provider-kubernetes/kubernetes(cached)

Release Note

Release note for CHANGELOG:

Suppress non-op changes in kubernetes_resource_quota resource

References

None.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@ghost ghost added size/XS labels Apr 29, 2021
@hashicorp-cla
Copy link

hashicorp-cla commented Apr 29, 2021

CLA assistant check
All committers have signed the CLA.

@ecrousseau
Copy link
Contributor Author

I would like to note - I am not 100% sure this actually fixes the problem, because I'm not sure how to add new tests and/or make the test cover the specific situation I'm seeing... advice welcome!

@jrhouston jrhouston changed the title Update resource_kubernetes_resource_quota.go Add diff suppression for hard limits on kubernetes_resource_quota May 13, 2021
@jrhouston
Copy link
Collaborator

Thanks for fixing this @ecrousseau. I've added a commit that updates the test fixture for this to use a value that will get suppressed, i.e 2048Mi to become 2Gi. If the diff supress func is removed, you'll see a test failure because of a non-empty plan after the test was run.

@jrhouston jrhouston merged commit 9e96653 into hashicorp:main May 13, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants