terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

Add ForceNew: true to controller field in IngressClass resource

Open SaadAssaf opened this issue 1 year ago • 3 comments

Description

This PR fixes an issue where changes to the controller field in the IngressClass resource fail because it is immutable in Kubernetes (Kubernetes API). When attempting to update the controller value, Kubernetes rejects the change with an error:

spec.controller: Invalid value: "new-controller": field is immutable

The fix adds the ForceNew: true attribute to the controller field. Doing so makes sure that every change to the controller value forces Terraform to recreate the resource.

Acceptance tests

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

Output from acceptance testing:

make testacc TESTARGS='-run=TestAccKubernetesIngressClassV1_ControllerImmutable'
==> Checking that code complies with gofmt requirements...
go vet ./...
TF_ACC=1 go test "/home/saad/nine-Repos/PT-Repo/terraform-provider-kubernetes/kubernetes" -v -vet=off -run=TestAccKubernetesIngressClassV1_ControllerImmutable -parallel 8 
-timeout 3h
=== RUN   TestAccKubernetesIngressClassV1_ControllerImmutable
=== PAUSE TestAccKubernetesIngressClassV1_ControllerImmutable
=== CONT  TestAccKubernetesIngressClassV1_ControllerImmutable
--- PASS: TestAccKubernetesIngressClassV1_ControllerImmutable (2.74s)
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes   2.774s

Release Note

Release note for CHANGELOG:

`Fix: Add ForceNew to the controller field of IngressClass to handle immutability and ensure resource recreation when controller value changes.`

References

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

SaadAssaf avatar Nov 21 '24 15:11 SaadAssaf

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

hashicorp-cla-app[bot] avatar Nov 21 '24 15:11 hashicorp-cla-app[bot]

Hi, is there anything we can do to speed things up here? We would like to do some changes to ingress classes deployed on our k8s clusters and this change would help us.

thirdeyenick avatar Dec 04 '24 09:12 thirdeyenick

Could we have this somehow reviewed, please?

thirdeyenick avatar Jan 29 '25 08:01 thirdeyenick