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

azurerm_kubernetes_cluster - private_cluster_public_fqdn_enabled is no longer force new #13413

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

hieumoscow
Copy link
Contributor

Fix #13099, to do in place update for private_cluster_public_fqdn_enabled

Fix hashicorp#13099, to do in place update for `private_cluster_public_fqdn_enabled`
@LaurentLesle
Copy link
Contributor

would be good if someone can fast-track the review and get it in the next release as it is impacting customers with private clusters who need to upgrade to azurerm ~>= 2.73

Copy link
Collaborator

@aristosvo aristosvo left a comment

Choose a reason for hiding this comment

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

@hieumoscow It looks good to me besides the comment, but I'm not a maintainer tbh. I'll run the specific AccTest now to check if it is indeed working, will let you know.

Edit: Test is failing, see below

❯ make acctests SERVICE='containers' TESTARGS='-run=TestAccKubernetesCluster_privateClusterPublicFqdn'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/containers -run=TestAccKubernetesCluster_privateClusterPublicFqdn -timeout 180m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccKubernetesCluster_privateClusterPublicFqdn
=== PAUSE TestAccKubernetesCluster_privateClusterPublicFqdn
=== CONT  TestAccKubernetesCluster_privateClusterPublicFqdn
    testcase.go:88: Step 3/4 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # azurerm_kubernetes_cluster.test will be updated in-place
          ~ resource "azurerm_kubernetes_cluster" "test" {
                id                                  = "/subscriptions/<mysubscription>/resourcegroups/acctestRG-aks-210920150634755905/providers/Microsoft.ContainerService/managedClusters/acctestaks210920150634755905"
                name                                = "acctestaks210920150634755905"
              ~ private_cluster_public_fqdn_enabled = false -> true
                tags                                = {}
                # (16 unchanged attributes hidden)
        
        
        
        
        
        
                # (6 unchanged blocks hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccKubernetesCluster_privateClusterPublicFqdn (925.56s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-azurerm/internal/services/containers    927.181s
FAIL
make: *** [acctests] Error 1

It seems EnablePrivateClusterPublicFQDN is not updated/set in resourceKubernetesClusterUpdate, you should add it there somehow to make this work.

By adding below the test was passing, maybe that is enough to enable this functionality:

diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go
index 50534ab81..517fff0e7 100644
--- a/internal/services/containers/kubernetes_cluster_resource.go
+++ b/internal/services/containers/kubernetes_cluster_resource.go
@@ -1224,6 +1224,11 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}
                }
        }
 
+       if d.HasChange("private_cluster_public_fqdn_enabled") {
+               updateCluster = true
+               existing.ManagedClusterProperties.APIServerAccessProfile.EnablePrivateClusterPublicFQDN = utils.Bool(d.Get("private_cluster_public_fqdn_enabled").(bool))
+       }
+
        if d.HasChange("auto_scaler_profile") {
                updateCluster = true
                autoScalerProfileRaw := d.Get("auto_scaler_profile").([]interface{})

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the change @hieumoscow - could we update the docs to reflect this change and add/update/fix the update test so it passes to ensure this continues to work? thanks!

@hieumoscow
Copy link
Contributor Author

@katbyte I have updated per @aristosvo suggestion, I do not think we need to update the doc as there was no "Changing this forces a new resource to be created." phrase there before.

https://github.com/hieumoscow/terraform-provider-azurerm/blame/main/website/docs/r/kubernetes_cluster.html.markdown#L129

@hieumoscow
Copy link
Contributor Author

Ran the test locally, all passed!

@hieumoscow hieumoscow requested a review from katbyte September 22, 2021 13:24
@katbyte katbyte self-assigned this Sep 22, 2021
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @hieumoscow! LGTM now 🏗️

@katbyte katbyte changed the title private_cluster_public_fqdn_enabled in place update azurerm_kubernetes_cluster - private_cluster_public_fqdn_enabled is no longer force new Sep 23, 2021
@katbyte katbyte merged commit 072d02f into hashicorp:main Sep 23, 2021
@katbyte katbyte added the bug label Sep 23, 2021
katbyte added a commit that referenced this pull request Sep 23, 2021
@hieumoscow hieumoscow deleted the patch-1 branch September 27, 2021 07:19
@github-actions
Copy link

This functionality has been released in v2.78.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@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 contributions.
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 Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes cluster must be replaced because of private_cluster_public_fqdn_enabled
4 participants