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

Autopilot Suppressed Diff Prevents using additive_vpc_scope_dns_domain #11744

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2129,33 +2129,35 @@ func ResourceContainerCluster() *schema.Resource {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
DiffSuppressFunc: suppressDiffForAutopilot,
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this ends up being a breaking change in practice. Autopilot clusters that don't set a value at all get this back in the response:

  "dnsConfig": {
   "clusterDns": "CLOUD_DNS",
   "clusterDnsScope": "CLUSTER_SCOPE",
   "clusterDnsDomain": "cluster.local"
  },

Terraform will see a diff on that by removing the DSF on the top-level field, even though the subfields will be supressed. If there was not a default value for the block this would be safe.

Description: `Configuration for Cloud DNS for Kubernetes Engine.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"additive_vpc_scope_dns_domain": {
Type: schema.TypeString,
Description: `Enable additive VPC scope DNS in a GKE cluster.`,
Optional: true,
Type: schema.TypeString,
Description: `Enable additive VPC scope DNS in a GKE cluster.`,
Optional: true,
},
"cluster_dns": {
Type: schema.TypeString,
Default: "PROVIDER_UNSPECIFIED",
ValidateFunc: validation.StringInSlice([]string{"PROVIDER_UNSPECIFIED", "PLATFORM_DEFAULT", "CLOUD_DNS"}, false),
Description: `Which in-cluster DNS provider should be used.`,
Optional: true,
Type: schema.TypeString,
Default: "PROVIDER_UNSPECIFIED",
ValidateFunc: validation.StringInSlice([]string{"PROVIDER_UNSPECIFIED", "PLATFORM_DEFAULT", "CLOUD_DNS"}, false),
DiffSuppressFunc: suppressDiffForAutopilot,
Description: `Which in-cluster DNS provider should be used.`,
Optional: true,
},
"cluster_dns_scope": {
Type: schema.TypeString,
Default: "DNS_SCOPE_UNSPECIFIED",
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
Description: `The scope of access to cluster DNS records.`,
Optional: true,
Type: schema.TypeString,
Default: "DNS_SCOPE_UNSPECIFIED",
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
DiffSuppressFunc: suppressDiffForAutopilot,
Description: `The scope of access to cluster DNS records.`,
Optional: true,
},
"cluster_dns_domain": {
Type: schema.TypeString,
Description: `The suffix used for all cluster service records.`,
Optional: true,
Type: schema.TypeString,
Description: `The suffix used for all cluster service records.`,
DiffSuppressFunc: suppressDiffForAutopilot,
Optional: true,
},
},
},
Expand Down Expand Up @@ -6843,8 +6845,13 @@ func containerClusterAutopilotCustomizeDiff(_ context.Context, d *schema.Resourc
if err := d.SetNew("networking_mode", "VPC_NATIVE"); err != nil {
return err
}
}
return nil
}
// Additive VPC Scope DNS domain is supported in Autopilot but only on creation.
// If additive_vpc_scope_dns_domain is changed and enable_autopilot is true, force recreation.
if d.HasChange("dns_config.0.additive_vpc_scope_dns_domain") && d.Get("enable_autopilot").(bool) {
return d.ForceNew("dns_config.0.additive_vpc_scope_dns_domain")
}
return nil
}

// node_version only applies to the default node pool, so it should conflict with remove_default_node_pool = true
Expand Down