From 28cd0a68af328e6fcfd953320720a2d7363394ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Tue, 22 Oct 2024 13:45:11 -0300 Subject: [PATCH 01/13] Adds property. Updates the NodePoolUpdate function to rotate the node pool. Removes the ForceNew flag on properties. --- .../kubernetes_cluster_node_pool_resource.go | 115 +++++++++++++++--- 1 file changed, 97 insertions(+), 18 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 48a7a6304563..e862b8a6fb99 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -89,7 +89,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "name": { Type: pluginsdk.TypeString, Required: true, - ForceNew: true, ValidateFunc: containerValidate.KubernetesAgentPoolName, }, @@ -112,7 +111,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "vm_size": { Type: pluginsdk.TypeString, Required: true, - ForceNew: true, ValidateFunc: validation.StringIsNotEmpty, }, @@ -141,14 +139,13 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { }, false), }, - "kubelet_config": schemaNodePoolKubeletConfigForceNew(), + "kubelet_config": schemaNodePoolKubeletConfig(), - "linux_os_config": schemaNodePoolLinuxOSConfigForceNew(), + "linux_os_config": schemaNodePoolLinuxOSConfig(), "fips_enabled": { Type: pluginsdk.TypeBool, Optional: true, - ForceNew: true, }, "gpu_instance": { @@ -184,7 +181,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeInt, Optional: true, Computed: true, - ForceNew: true, }, "mode": { @@ -242,7 +238,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "os_disk_size_gb": { Type: pluginsdk.TypeInt, Optional: true, - ForceNew: true, Computed: true, ValidateFunc: validation.IntAtLeast(1), }, @@ -250,7 +245,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "os_disk_type": { Type: pluginsdk.TypeString, Optional: true, - ForceNew: true, Default: agentpools.OSDiskTypeManaged, ValidateFunc: validation.StringInSlice([]string{ string(agentpools.OSDiskTypeEphemeral), @@ -284,7 +278,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "pod_subnet_id": { Type: pluginsdk.TypeString, Optional: true, - ForceNew: true, ValidateFunc: commonids.ValidateSubnetID, }, @@ -309,7 +302,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "snapshot_id": { Type: pluginsdk.TypeString, Optional: true, - ForceNew: true, ValidateFunc: snapshots.ValidateSnapshotID, }, @@ -331,9 +323,14 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { }, false), }, + "temporary_name_for_rotation": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: containerValidate.KubernetesAgentPoolName, + }, + "ultra_ssd_enabled": { Type: pluginsdk.TypeBool, - ForceNew: true, Default: false, Optional: true, }, @@ -341,7 +338,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "vnet_subnet_id": { Type: pluginsdk.TypeString, Optional: true, - ForceNew: true, ValidateFunc: commonids.ValidateSubnetID, }, @@ -389,7 +385,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "host_encryption_enabled": { Type: pluginsdk.TypeBool, Optional: true, - ForceNew: true, }, } @@ -825,11 +820,95 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.MinCount = nil } - log.Printf("[DEBUG] Updating existing %s..", *id) - existing.Model.Properties = props - err = client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model) - if err != nil { - return fmt.Errorf("updating Node Pool %s: %+v", *id, err) + cycleNodePoolProperties := []string{ + "fips_enabled", + "host_encryption_enabled", + "kubelet_config", + "linux_os_config", + "max_pods", + "name", + "os_disk_size_gb", + "os_disk_type", + "pod_subnet_id", + "snapshot_id", + "ultra_ssd_enabled", + "vm_size", + "vnet_subnet_id", + "zones", + } + + // if the node pool name has changed, it means the initial attempt at resizing failed + cycleNodePool := d.HasChanges(cycleNodePoolProperties...) + // os_sku can only be updated if the current and new os_sku are either Ubuntu or AzureLinux + if d.HasChange("os_sku") { + oldOsSkuRaw, newOsSkuRaw := d.GetChange("os_sku") + oldOsSku := oldOsSkuRaw.(string) + newOsSku := newOsSkuRaw.(string) + if oldOsSku != string(managedclusters.OSSKUUbuntu) && oldOsSku != string(managedclusters.OSSKUAzureLinux) { + cycleNodePool = true + } + if newOsSku != string(managedclusters.OSSKUUbuntu) && newOsSku != string(managedclusters.OSSKUAzureLinux) { + cycleNodePool = true + } + } + if cycleNodePool { + log.Printf("[DEBUG] Cycling Node Pool..") + // to provide a seamless updating experience for the node pool we need to cycle it by provisioning a temporary one, + // tearing down the existing node pool and then bringing up the new one. + + if v := d.Get("temporary_name_for_rotation").(string); v == "" { + return fmt.Errorf("`temporary_name_for_rotation` must be specified when updating any of the following properties %q", cycleNodePoolProperties) + } + + temporaryNodePoolName := d.Get("temporary_name_for_rotation").(string) + tempNodePoolId := agentpools.NewAgentPoolID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, temporaryNodePoolName) + + tempExisting, err := client.Get(ctx, tempNodePoolId) + if !response.WasNotFound(tempExisting.HttpResponse) && err != nil { + return fmt.Errorf("checking for existing temporary %s: %+v", tempNodePoolId, err) + } + + defaultExisting, err := client.Get(ctx, *id) + if !response.WasNotFound(defaultExisting.HttpResponse) && err != nil { + return fmt.Errorf("checking for existing node pool %s: %+v", *id, err) + } + + agentProfile := *defaultExisting.Model + tempAgentProfile := agentProfile + tempAgentProfile.Name = &temporaryNodePoolName + // if the temp node pool already exists due to a previous failure, don't bother spinning it up + if tempExisting.Model == nil { + if err := retrySystemNodePoolCreation(ctx, client, tempNodePoolId, tempAgentProfile); err != nil { + return fmt.Errorf("creating temporary %s: %+v", tempNodePoolId, err) + } + } + + // delete the old node pool if it exists + if defaultExisting.Model != nil { + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting old %s: %+v", *id, err) + } + } + + // create the new node pool with the new data + if err := retrySystemNodePoolCreation(ctx, client, *id, agentProfile); err != nil { + log.Printf("[DEBUG] Creation of redefined node pool failed") + return fmt.Errorf("creating default %s: %+v", *id, err) + } + + if err := client.DeleteThenPoll(ctx, tempNodePoolId); err != nil { + return fmt.Errorf("deleting temporary %s: %+v", tempNodePoolId, err) + } + + log.Printf("[DEBUG] Cycled Node Pool..") + } else { + + log.Printf("[DEBUG] Updating existing %s..", *id) + existing.Model.Properties = props + err = client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model) + if err != nil { + return fmt.Errorf("updating Node Pool %s: %+v", *id, err) + } } d.Partial(false) From 9f16c5f061f901966124839102a623e0b1c153b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Wed, 23 Oct 2024 17:26:40 -0300 Subject: [PATCH 02/13] Updating tests. Restoring name as ForceNew. --- .../kubernetes_cluster_node_pool_resource.go | 4 +-- ...ernetes_cluster_node_pool_resource_test.go | 28 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index e862b8a6fb99..ab5b984b4b6d 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -89,6 +89,7 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "name": { Type: pluginsdk.TypeString, Required: true, + ForceNew: true, ValidateFunc: containerValidate.KubernetesAgentPoolName, }, @@ -369,7 +370,7 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { }, false), }, - "zones": commonschema.ZonesMultipleOptionalForceNew(), + "zones": commonschema.ZonesMultipleOptional(), "auto_scaling_enabled": { Type: pluginsdk.TypeBool, @@ -826,7 +827,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int "kubelet_config", "linux_os_config", "max_pods", - "name", "os_disk_size_gb", "os_disk_type", "pod_subnet_id", diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go b/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go index 38cacc41258a..59e8f4d003d8 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go @@ -337,14 +337,14 @@ func TestAccKubernetesClusterNodePool_manualScaleVMSku(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("temporary_name_for_rotation"), { Config: r.manualScaleVMSkuConfig(data, "Standard_F4s_v2"), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("temporary_name_for_rotation"), }) } @@ -774,14 +774,14 @@ func TestAccKubernetesClusterNodePool_ultraSSD(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("temporary_name_for_rotation"), { Config: r.ultraSSD(data, true), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("temporary_name_for_rotation"), }) } @@ -1737,10 +1737,11 @@ provider "azurerm" { %s resource "azurerm_kubernetes_cluster_node_pool" "test" { - name = "internal" - kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id - vm_size = "%s" - node_count = 1 + name = "internal" + kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id + vm_size = "%s" + node_count = 1 + temporary_name_for_rotation = "temporal" } `, r.templateConfig(data), sku) } @@ -2505,11 +2506,12 @@ resource "azurerm_kubernetes_cluster" "test" { } } resource "azurerm_kubernetes_cluster_node_pool" "test" { - name = "internal" - kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id - vm_size = "Standard_D2s_v3" - ultra_ssd_enabled = %t - zones = ["1", "2", "3"] + name = "internal" + kubernetes_cluster_id = azurerm_kubernetes_cluster.test.id + vm_size = "Standard_D2s_v3" + temporary_name_for_rotation = "temporal" + ultra_ssd_enabled = %t + zones = ["1", "2", "3"] } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, ultraSSDEnabled) } From bea1b629f833eb3ab02cd3f9e5ec75416e98a5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Wed, 23 Oct 2024 18:49:10 -0300 Subject: [PATCH 03/13] Updating Docs. --- .../kubernetes_cluster_node_pool_resource.go | 2 +- ...kubernetes_cluster_node_pool.html.markdown | 52 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index ab5b984b4b6d..810865b21213 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -380,7 +380,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { "node_public_ip_enabled": { Type: pluginsdk.TypeBool, Optional: true, - ForceNew: true, }, "host_encryption_enabled": { @@ -827,6 +826,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int "kubelet_config", "linux_os_config", "max_pods", + "node_public_ip_enabled", "os_disk_size_gb", "os_disk_type", "pod_subnet_id", diff --git a/website/docs/r/kubernetes_cluster_node_pool.html.markdown b/website/docs/r/kubernetes_cluster_node_pool.html.markdown index 32533569cf5c..2d26e3be46aa 100644 --- a/website/docs/r/kubernetes_cluster_node_pool.html.markdown +++ b/website/docs/r/kubernetes_cluster_node_pool.html.markdown @@ -14,6 +14,8 @@ Manages a Node Pool within a Kubernetes Cluster ~> **NOTE:** Multiple Node Pools are only supported when the Kubernetes Cluster is using Virtual Machine Scale Sets. +-> **Note:** Changing certain properties is done by cycling the node pool. When cycling it, it doesn’t perform cordon and drain, and it will disrupt rescheduling pods currently running on the previous node pool. `temporary_name_for_rotation` must be specified when changing any of the following properties: `fips_enabled`, `host_encryption_enabled`, `kubelet_config`, `linux_os_config`, `max_pods`, `node_public_ip_enabled`, `os_disk_size_gb`, `os_disk_type`, `pod_subnet_id`, `snapshot_id`, `ultra_ssd_enabled`, `vm_size`, `vnet_subnet_id`, `zones`. + ## Example Usage This example provisions a basic Kubernetes Node Pool. Other examples of the `azurerm_kubernetes_cluster_node_pool` resource can be found in [the `./examples/kubernetes` directory within the GitHub Repository](https://github.com/hashicorp/terraform-provider-azurerm/tree/main/examples/kubernetes) @@ -66,19 +68,19 @@ The following arguments are supported: ~> **NOTE:** The type of Default Node Pool for the Kubernetes Cluster must be `VirtualMachineScaleSets` to attach multiple node pools. -* `vm_size` - (Required) The SKU which should be used for the Virtual Machines used in this Node Pool. Changing this forces a new resource to be created. +* `vm_size` - (Required) The SKU which should be used for the Virtual Machines used in this Node Pool. Changing this property requires specifying `temporary_name_for_rotation`. --- -* `capacity_reservation_group_id` - (Optional) Specifies the ID of the Capacity Reservation Group where this Node Pool should exist. Changing this forces a new resource to be created. +* `capacity_reservation_group_id` - (Optional) Specifies the ID of the Capacity Reservation Group where this Node Pool should exist. Changing this property requires specifying `temporary_name_for_rotation`. * `auto_scaling_enabled` - (Optional) Whether to enable [auto-scaler](https://docs.microsoft.com/azure/aks/cluster-autoscaler). -* `host_encryption_enabled` - (Optional) Should the nodes in this Node Pool have host encryption enabled? Changing this forces a new resource to be created. +* `host_encryption_enabled` - (Optional) Should the nodes in this Node Pool have host encryption enabled? Changing this property requires specifying `temporary_name_for_rotation`. ~> **NOTE:** Additional fields must be configured depending on the value of this field - see below. -* `node_public_ip_enabled` - (Optional) Should each node have a Public IP Address? Changing this forces a new resource to be created. +* `node_public_ip_enabled` - (Optional) Should each node have a Public IP Address? Changing this property requires specifying `temporary_name_for_rotation`. * `eviction_policy` - (Optional) The Eviction Policy which should be used for Virtual Machines within the Virtual Machine Scale Set powering this Node Pool. Possible values are `Deallocate` and `Delete`. Changing this forces a new resource to be created. @@ -86,11 +88,11 @@ The following arguments are supported: * `host_group_id` - (Optional) The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from. Changing this forces a new resource to be created. -* `kubelet_config` - (Optional) A `kubelet_config` block as defined below. Changing this forces a new resource to be created. +* `kubelet_config` - (Optional) A `kubelet_config` block as defined below. Changing this property requires specifying `temporary_name_for_rotation`. -* `linux_os_config` - (Optional) A `linux_os_config` block as defined below. Changing this forces a new resource to be created. +* `linux_os_config` - (Optional) A `linux_os_config` block as defined below. Changing this property requires specifying `temporary_name_for_rotation`. -* `fips_enabled` - (Optional) Should the nodes in this Node Pool have Federal Information Processing Standard enabled? Changing this forces a new resource to be created. +* `fips_enabled` - (Optional) Should the nodes in this Node Pool have Federal Information Processing Standard enabled? Changing this property requires specifying `temporary_name_for_rotation`. ~> **Note:** FIPS support is in Public Preview - more information and details on how to opt into the Preview can be found in [this article](https://docs.microsoft.com/azure/aks/use-multiple-node-pools#add-a-fips-enabled-node-pool-preview). @@ -98,7 +100,7 @@ The following arguments are supported: * `kubelet_disk_type` - (Optional) The type of disk used by kubelet. Possible values are `OS` and `Temporary`. -* `max_pods` - (Optional) The maximum number of pods that can run on each agent. Changing this forces a new resource to be created. +* `max_pods` - (Optional) The maximum number of pods that can run on each agent. Changing this property requires specifying `temporary_name_for_rotation`. * `mode` - (Optional) Should this Node Pool be used for System or User resources? Possible values are `System` and `User`. Defaults to `User`. @@ -114,15 +116,15 @@ The following arguments are supported: -> **Note:** This version must be supported by the Kubernetes Cluster - as such the version of Kubernetes used on the Cluster/Control Plane may need to be upgraded first. -* `os_disk_size_gb` - (Optional) The Agent Operating System disk size in GB. Changing this forces a new resource to be created. +* `os_disk_size_gb` - (Optional) The Agent Operating System disk size in GB. Changing this property requires specifying `temporary_name_for_rotation`. -* `os_disk_type` - (Optional) The type of disk which should be used for the Operating System. Possible values are `Ephemeral` and `Managed`. Defaults to `Managed`. Changing this forces a new resource to be created. +* `os_disk_type` - (Optional) The type of disk which should be used for the Operating System. Possible values are `Ephemeral` and `Managed`. Defaults to `Managed`. Changing this property requires specifying `temporary_name_for_rotation`. -* `pod_subnet_id` - (Optional) The ID of the Subnet where the pods in the Node Pool should exist. Changing this forces a new resource to be created. +* `pod_subnet_id` - (Optional) The ID of the Subnet where the pods in the Node Pool should exist. Changing this property requires specifying `temporary_name_for_rotation`. * `os_sku` - (Optional) Specifies the OS SKU used by the agent pool. Possible values are `AzureLinux`, `Ubuntu`, `Windows2019` and `Windows2022`. If not specified, the default is `Ubuntu` if OSType=Linux or `Windows2019` if OSType=Windows. And the default Windows OSSKU will be changed to `Windows2022` after Windows2019 is deprecated. Changing this from `AzureLinux` or `Ubuntu` to `AzureLinux` or `Ubuntu` will not replace the resource, otherwise it forces a new resource to be created. -* `os_type` - (Optional) The Operating System which should be used for this Node Pool. Changing this forces a new resource to be created. Possible values are `Linux` and `Windows`. Defaults to `Linux`. +* `os_type` - (Optional) The Operating System which should be used for this Node Pool. Changing this property requires specifying `temporary_name_for_rotation`. Possible values are `Linux` and `Windows`. Defaults to `Linux`. * `priority` - (Optional) The Priority for Virtual Machines within the Virtual Machine Scale Set that powers this Node Pool. Possible values are `Regular` and `Spot`. Defaults to `Regular`. Changing this forces a new resource to be created. @@ -134,7 +136,7 @@ The following arguments are supported: ~> **Note:** This field can only be configured when `priority` is set to `Spot`. -* `snapshot_id` - (Optional) The ID of the Snapshot which should be used to create this Node Pool. Changing this forces a new resource to be created. +* `snapshot_id` - (Optional) The ID of the Snapshot which should be used to create this Node Pool. Changing this property requires specifying `temporary_name_for_rotation`. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -142,11 +144,11 @@ The following arguments are supported: * `scale_down_mode` - (Optional) Specifies how the node pool should deal with scaled-down nodes. Allowed values are `Delete` and `Deallocate`. Defaults to `Delete`. -* `ultra_ssd_enabled` - (Optional) Used to specify whether the UltraSSD is enabled in the Node Pool. Defaults to `false`. See [the documentation](https://docs.microsoft.com/azure/aks/use-ultra-disks) for more information. Changing this forces a new resource to be created. +* `ultra_ssd_enabled` - (Optional) Used to specify whether the UltraSSD is enabled in the Node Pool. Defaults to `false`. See [the documentation](https://docs.microsoft.com/azure/aks/use-ultra-disks) for more information. Changing this property requires specifying `temporary_name_for_rotation`. * `upgrade_settings` - (Optional) A `upgrade_settings` block as documented below. -* `vnet_subnet_id` - (Optional) The ID of the Subnet where this Node Pool should exist. Changing this forces a new resource to be created. +* `vnet_subnet_id` - (Optional) The ID of the Subnet where this Node Pool should exist. Changing this property requires specifying `temporary_name_for_rotation`. ~> **NOTE:** A route table must be configured on this Subnet. @@ -178,25 +180,25 @@ If `auto_scaling_enabled` is set to `false`, then the following fields can also A `kubelet_config` block supports the following: -* `allowed_unsafe_sysctls` - (Optional) Specifies the allow list of unsafe sysctls command or patterns (ending in `*`). Changing this forces a new resource to be created. +* `allowed_unsafe_sysctls` - (Optional) Specifies the allow list of unsafe sysctls command or patterns (ending in `*`). -* `container_log_max_line` - (Optional) Specifies the maximum number of container log files that can be present for a container. must be at least 2. Changing this forces a new resource to be created. +* `container_log_max_line` - (Optional) Specifies the maximum number of container log files that can be present for a container. must be at least 2. -* `container_log_max_size_mb` - (Optional) Specifies the maximum size (e.g. 10MB) of container log file before it is rotated. Changing this forces a new resource to be created. +* `container_log_max_size_mb` - (Optional) Specifies the maximum size (e.g. 10MB) of container log file before it is rotated. -* `cpu_cfs_quota_enabled` - (Optional) Is CPU CFS quota enforcement for containers enabled? Changing this forces a new resource to be created. +* `cpu_cfs_quota_enabled` - (Optional) Is CPU CFS quota enforcement for containers enabled? -* `cpu_cfs_quota_period` - (Optional) Specifies the CPU CFS quota period value. Changing this forces a new resource to be created. +* `cpu_cfs_quota_period` - (Optional) Specifies the CPU CFS quota period value. -* `cpu_manager_policy` - (Optional) Specifies the CPU Manager policy to use. Possible values are `none` and `static`, Changing this forces a new resource to be created. +* `cpu_manager_policy` - (Optional) Specifies the CPU Manager policy to use. Possible values are `none` and `static`, -* `image_gc_high_threshold` - (Optional) Specifies the percent of disk usage above which image garbage collection is always run. Must be between `0` and `100`. Changing this forces a new resource to be created. +* `image_gc_high_threshold` - (Optional) Specifies the percent of disk usage above which image garbage collection is always run. Must be between `0` and `100`. -* `image_gc_low_threshold` - (Optional) Specifies the percent of disk usage lower than which image garbage collection is never run. Must be between `0` and `100`. Changing this forces a new resource to be created. +* `image_gc_low_threshold` - (Optional) Specifies the percent of disk usage lower than which image garbage collection is never run. Must be between `0` and `100`. -* `pod_max_pid` - (Optional) Specifies the maximum number of processes per pod. Changing this forces a new resource to be created. +* `pod_max_pid` - (Optional) Specifies the maximum number of processes per pod. -* `topology_manager_policy` - (Optional) Specifies the Topology Manager policy to use. Possible values are `none`, `best-effort`, `restricted` or `single-numa-node`. Changing this forces a new resource to be created. +* `topology_manager_policy` - (Optional) Specifies the Topology Manager policy to use. Possible values are `none`, `best-effort`, `restricted` or `single-numa-node`. --- From 262a984613d58c267ecea8ec9efd115e93bc6252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Fri, 25 Oct 2024 16:28:26 -0300 Subject: [PATCH 04/13] Fixing value assignment. Deleting obsolete methods. Renaming `retrySystemNodePoolCreation` to `retryNodePoolCreation`. --- .../kubernetes_cluster_node_pool_resource.go | 25 ++-- .../containers/kubernetes_cluster_resource.go | 8 +- .../containers/kubernetes_nodepool.go | 134 ------------------ 3 files changed, 16 insertions(+), 151 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 810865b21213..c18be2b7867d 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -820,6 +820,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.MinCount = nil } + // evaluate if the nodepool needs to be cycled cycleNodePoolProperties := []string{ "fips_enabled", "host_encryption_enabled", @@ -851,6 +852,10 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int cycleNodePool = true } } + + // updating the properties values + existing.Model.Properties = props + if cycleNodePool { log.Printf("[DEBUG] Cycling Node Pool..") // to provide a seamless updating experience for the node pool we need to cycle it by provisioning a temporary one, @@ -865,33 +870,28 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int tempExisting, err := client.Get(ctx, tempNodePoolId) if !response.WasNotFound(tempExisting.HttpResponse) && err != nil { - return fmt.Errorf("checking for existing temporary %s: %+v", tempNodePoolId, err) - } - - defaultExisting, err := client.Get(ctx, *id) - if !response.WasNotFound(defaultExisting.HttpResponse) && err != nil { - return fmt.Errorf("checking for existing node pool %s: %+v", *id, err) + return fmt.Errorf("checking for existing temporary node pool %s: %+v", tempNodePoolId, err) } - agentProfile := *defaultExisting.Model - tempAgentProfile := agentProfile + tempAgentProfile := *existing.Model tempAgentProfile.Name = &temporaryNodePoolName - // if the temp node pool already exists due to a previous failure, don't bother spinning it up + // if the temp node pool already exists due to a previous failure, don't bother spinning it up. + // the temporary nodepool is created with the new values if tempExisting.Model == nil { - if err := retrySystemNodePoolCreation(ctx, client, tempNodePoolId, tempAgentProfile); err != nil { + if err := retryNodePoolCreation(ctx, client, tempNodePoolId, tempAgentProfile); err != nil { return fmt.Errorf("creating temporary %s: %+v", tempNodePoolId, err) } } // delete the old node pool if it exists - if defaultExisting.Model != nil { + if existing.Model != nil { if err := client.DeleteThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting old %s: %+v", *id, err) } } // create the new node pool with the new data - if err := retrySystemNodePoolCreation(ctx, client, *id, agentProfile); err != nil { + if err := retryNodePoolCreation(ctx, client, *id, *existing.Model); err != nil { log.Printf("[DEBUG] Creation of redefined node pool failed") return fmt.Errorf("creating default %s: %+v", *id, err) } @@ -904,7 +904,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } else { log.Printf("[DEBUG] Updating existing %s..", *id) - existing.Model.Properties = props err = client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model) if err != nil { return fmt.Errorf("updating Node Pool %s: %+v", *id, err) diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go index c2d75539f059..96e5dcafb3fe 100644 --- a/internal/services/containers/kubernetes_cluster_resource.go +++ b/internal/services/containers/kubernetes_cluster_resource.go @@ -2727,7 +2727,7 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{} tempAgentProfile.Name = &temporaryNodePoolName // if the temp node pool already exists due to a previous failure, don't bother spinning it up if tempExisting.Model == nil { - if err := retrySystemNodePoolCreation(ctx, nodePoolsClient, tempNodePoolId, tempAgentProfile); err != nil { + if err := retryNodePoolCreation(ctx, nodePoolsClient, tempNodePoolId, tempAgentProfile); err != nil { return fmt.Errorf("creating temporary %s: %+v", tempNodePoolId, err) } } @@ -2740,7 +2740,7 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{} } // create the default node pool with the new vm size - if err := retrySystemNodePoolCreation(ctx, nodePoolsClient, defaultNodePoolId, agentProfile); err != nil { + if err := retryNodePoolCreation(ctx, nodePoolsClient, defaultNodePoolId, agentProfile); err != nil { // if creation of the default node pool fails we automatically fall back to the temporary node pool // in func findDefaultNodePool log.Printf("[DEBUG] Creation of resized default node pool failed") @@ -5041,8 +5041,8 @@ func flattenKubernetesClusterMetricsProfile(input *managedclusters.ManagedCluste return pointer.From(input.CostAnalysis.Enabled) } -func retrySystemNodePoolCreation(ctx context.Context, client *agentpools.AgentPoolsClient, id agentpools.AgentPoolId, profile agentpools.AgentPool) error { - // retries the creation of a system node pool 3 times +func retryNodePoolCreation(ctx context.Context, client *agentpools.AgentPoolsClient, id agentpools.AgentPoolId, profile agentpools.AgentPool) error { + // retries the creation of a node pool 3 times var err error for attempt := 0; attempt < 3; attempt++ { if err = client.CreateOrUpdateThenPoll(ctx, id, profile); err == nil { diff --git a/internal/services/containers/kubernetes_nodepool.go b/internal/services/containers/kubernetes_nodepool.go index beee8363b934..d54659cf79f0 100644 --- a/internal/services/containers/kubernetes_nodepool.go +++ b/internal/services/containers/kubernetes_nodepool.go @@ -354,96 +354,6 @@ func schemaNodePoolKubeletConfig() *pluginsdk.Schema { } } -func schemaNodePoolKubeletConfigForceNew() *pluginsdk.Schema { - return &pluginsdk.Schema{ - Type: pluginsdk.TypeList, - Optional: true, - ForceNew: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "cpu_manager_policy": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "none", - "static", - }, false), - }, - - "cpu_cfs_quota_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - ForceNew: true, - }, - - "cpu_cfs_quota_period": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - }, - - "image_gc_high_threshold": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "image_gc_low_threshold": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "topology_manager_policy": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "none", - "best-effort", - "restricted", - "single-numa-node", - }, false), - }, - - "allowed_unsafe_sysctls": { - Type: pluginsdk.TypeSet, - Optional: true, - ForceNew: true, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - }, - }, - - "container_log_max_size_mb": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - }, - - // TODO 5.0: change this to `container_log_max_files` - "container_log_max_line": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntAtLeast(2), - }, - - "pod_max_pid": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - }, - }, - }, - } -} - func schemaNodePoolLinuxOSConfig() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, @@ -484,50 +394,6 @@ func schemaNodePoolLinuxOSConfig() *pluginsdk.Schema { } } -func schemaNodePoolLinuxOSConfigForceNew() *pluginsdk.Schema { - return &pluginsdk.Schema{ - Type: pluginsdk.TypeList, - Optional: true, - ForceNew: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "sysctl_config": schemaNodePoolSysctlConfigForceNew(), - - "transparent_huge_page_enabled": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "always", - "madvise", - "never", - }, false), - }, - - "transparent_huge_page_defrag": { - Type: pluginsdk.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - "always", - "defer", - "defer+madvise", - "madvise", - "never", - }, false), - }, - - "swap_file_size_mb": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - }, - }, - }, - } -} - func schemaNodePoolSysctlConfig() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, From aacec00978c18492092ca8c01d6be9dd31818d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Mon, 28 Oct 2024 13:19:19 -0300 Subject: [PATCH 05/13] Updating properties values from HCL definition. --- .../kubernetes_cluster_node_pool_resource.go | 86 ++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index c18be2b7867d..7dd0ccf00b2f 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -718,10 +718,41 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.EnableAutoScaling = utils.Bool(enableAutoScaling) } + if d.HasChange("fips_enabled") { + props.EnableFIPS = utils.Bool(d.Get("fips_enabled").(bool)) + } + + if d.HasChange("host_encryption_enabled") { + props.EnableEncryptionAtHost = utils.Bool(d.Get("host_encryption_enabled").(bool)) + } + + if d.HasChange("kubelet_config") { + if kubeletConfig := d.Get("kubelet_config").([]interface{}); len(kubeletConfig) > 0 { + props.KubeletConfig = expandAgentPoolKubeletConfig(kubeletConfig) + } + } + + if d.HasChange("linux_os_config") { + if linuxOSConfig := d.Get("linux_os_config").([]interface{}); len(linuxOSConfig) > 0 { + if d.Get("os_type").(string) != string(managedclusters.OSTypeLinux) { + return fmt.Errorf("`linux_os_config` can only be configured when `os_type` is set to `linux`") + } + linuxOSConfig, err := expandAgentPoolLinuxOSConfig(linuxOSConfig) + if err != nil { + return err + } + props.LinuxOSConfig = linuxOSConfig + } + } + if d.HasChange("max_count") || enableAutoScaling { props.MaxCount = utils.Int64(int64(d.Get("max_count").(int))) } + if d.HasChange("max_pods") { + props.MaxPods = utils.Int64(int64(d.Get("max_pods").(int))) + } + if d.HasChange("mode") { mode := agentpools.AgentPoolMode(d.Get("mode").(string)) props.Mode = &mode @@ -735,6 +766,10 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.Count = utils.Int64(int64(d.Get("node_count").(int))) } + if d.HasChange("node_public_ip_enabled") { + props.EnableNodePublicIP = utils.Bool(d.Get("node_public_ip_enabled").(bool)) + } + if d.HasChange("node_public_ip_prefix_id") { props.NodePublicIPPrefixID = utils.String(d.Get("node_public_ip_prefix_id").(string)) } @@ -763,10 +798,26 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.Tags = tags.Expand(t) } + if d.HasChange("os_disk_type") { + props.OsDiskType = pointer.To(agentpools.OSDiskType(d.Get("os_disk_type").(string))) + } + + if d.HasChange("os_disk_size_gb") { + props.OsDiskSizeGB = utils.Int64(int64(d.Get("os_disk_size_gb").(int))) + } + if d.HasChange("os_sku") { props.OsSKU = pointer.To(agentpools.OSSKU(d.Get("os_sku").(string))) } + if d.HasChange("pod_subnet_id") { + props.PodSubnetID = utils.String(d.Get("pod_subnet_id").(string)) + } + + if d.HasChange("ultra_ssd_enabled") { + props.EnableUltraSSD = utils.Bool(d.Get("ultra_ssd_enabled").(bool)) + } + if d.HasChange("upgrade_settings") { upgradeSettingsRaw := d.Get("upgrade_settings").([]interface{}) props.UpgradeSettings = expandAgentPoolUpgradeSettings(upgradeSettingsRaw) @@ -776,6 +827,30 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int mode := agentpools.ScaleDownMode(d.Get("scale_down_mode").(string)) props.ScaleDownMode = &mode } + + if d.HasChange("snapshot_id") { + props.CreationData = &agentpools.CreationData{ + SourceResourceId: utils.String(d.Get("snapshot_id").(string)), + } + } + + if d.HasChange("vm_size") { + props.VMSize = utils.String(d.Get("vm_size").(string)) + } + + if d.HasChange("vnet_subnet_id") { + var subnetID *commonids.SubnetId + if subnetIDValue, ok := d.GetOk("vnet_subnet_id"); ok { + subnetID, err = commonids.ParseSubnetID(subnetIDValue.(string)) + if err != nil { + return err + } + if subnetID != nil { + props.VnetSubnetID = utils.String(subnetID.ID()) + } + } + } + if d.HasChange("workload_runtime") { runtime := agentpools.WorkloadRuntime(d.Get("workload_runtime").(string)) props.WorkloadRuntime = &runtime @@ -793,6 +868,13 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int props.NetworkProfile = expandAgentPoolNetworkProfile(d.Get("node_network_profile").([]interface{})) } + if d.HasChange("zones") { + zones := zones.ExpandUntyped(d.Get("zones").(*schema.Set).List()) + if len(zones) > 0 { + props.AvailabilityZones = &zones + } + } + // validate the auto-scale fields are both set/unset to prevent a continual diff maxCount := 0 if props.MaxCount != nil { @@ -853,9 +935,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } } - // updating the properties values - existing.Model.Properties = props - if cycleNodePool { log.Printf("[DEBUG] Cycling Node Pool..") // to provide a seamless updating experience for the node pool we need to cycle it by provisioning a temporary one, @@ -875,6 +954,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int tempAgentProfile := *existing.Model tempAgentProfile.Name = &temporaryNodePoolName + // if the temp node pool already exists due to a previous failure, don't bother spinning it up. // the temporary nodepool is created with the new values if tempExisting.Model == nil { From 9587d0f2ca29e1c2332a85b7769cc7b753efb4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Mon, 28 Oct 2024 14:14:22 -0300 Subject: [PATCH 06/13] Remove unused function (schemaNodePoolSysctlConfigForceNew) --- .../containers/kubernetes_nodepool.go | 214 ------------------ 1 file changed, 214 deletions(-) diff --git a/internal/services/containers/kubernetes_nodepool.go b/internal/services/containers/kubernetes_nodepool.go index d54659cf79f0..950988fcd8ad 100644 --- a/internal/services/containers/kubernetes_nodepool.go +++ b/internal/services/containers/kubernetes_nodepool.go @@ -578,220 +578,6 @@ func schemaNodePoolSysctlConfig() *pluginsdk.Schema { } } -func schemaNodePoolSysctlConfigForceNew() *pluginsdk.Schema { - return &pluginsdk.Schema{ - Type: pluginsdk.TypeList, - Optional: true, - ForceNew: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "fs_aio_max_nr": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(65536, 6553500), - }, - - "fs_file_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(8192, 12000500), - }, - - "fs_inotify_max_user_watches": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(781250, 2097152), - }, - - "fs_nr_open": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(8192, 20000500), - }, - - "kernel_threads_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(20, 513785), - }, - - "net_core_netdev_max_backlog": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(1000, 3240000), - }, - - "net_core_optmem_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(20480, 4194304), - }, - - "net_core_rmem_default": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(212992, 134217728), - }, - - "net_core_rmem_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(212992, 134217728), - }, - - "net_core_somaxconn": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(4096, 3240000), - }, - - "net_core_wmem_default": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(212992, 134217728), - }, - - "net_core_wmem_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(212992, 134217728), - }, - - "net_ipv4_ip_local_port_range_min": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(1024, 60999), - }, - - "net_ipv4_ip_local_port_range_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(32768, 65535), - }, - - "net_ipv4_neigh_default_gc_thresh1": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(128, 80000), - }, - - "net_ipv4_neigh_default_gc_thresh2": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(512, 90000), - }, - - "net_ipv4_neigh_default_gc_thresh3": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(1024, 100000), - }, - - "net_ipv4_tcp_fin_timeout": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(5, 120), - }, - - "net_ipv4_tcp_keepalive_intvl": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(10, 90), - }, - - "net_ipv4_tcp_keepalive_probes": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(1, 15), - }, - - "net_ipv4_tcp_keepalive_time": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(30, 432000), - }, - - "net_ipv4_tcp_max_syn_backlog": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(128, 3240000), - }, - - "net_ipv4_tcp_max_tw_buckets": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(8000, 1440000), - }, - - "net_ipv4_tcp_tw_reuse": { - Type: pluginsdk.TypeBool, - Optional: true, - ForceNew: true, - }, - - "net_netfilter_nf_conntrack_buckets": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(65536, 524288), - }, - - "net_netfilter_nf_conntrack_max": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(131072, 2097152), - }, - - "vm_max_map_count": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(65530, 262144), - }, - - "vm_swappiness": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - - "vm_vfs_cache_pressure": { - Type: pluginsdk.TypeInt, - Optional: true, - ForceNew: true, - ValidateFunc: validation.IntBetween(0, 100), - }, - }, - }, - } -} - func schemaNodePoolNetworkProfile() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, From 10394d4cb3099e97f4be161bce92baa6e18511b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Wed, 6 Nov 2024 08:14:45 -0300 Subject: [PATCH 07/13] Fixing docs --- ...kubernetes_cluster_node_pool.html.markdown | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/website/docs/r/kubernetes_cluster_node_pool.html.markdown b/website/docs/r/kubernetes_cluster_node_pool.html.markdown index 2d26e3be46aa..8dd7027d3f79 100644 --- a/website/docs/r/kubernetes_cluster_node_pool.html.markdown +++ b/website/docs/r/kubernetes_cluster_node_pool.html.markdown @@ -72,7 +72,7 @@ The following arguments are supported: --- -* `capacity_reservation_group_id` - (Optional) Specifies the ID of the Capacity Reservation Group where this Node Pool should exist. Changing this property requires specifying `temporary_name_for_rotation`. +* `capacity_reservation_group_id` - (Optional) Specifies the ID of the Capacity Reservation Group where this Node Pool should exist. Changing this forces a new resource to be created. * `auto_scaling_enabled` - (Optional) Whether to enable [auto-scaler](https://docs.microsoft.com/azure/aks/cluster-autoscaler). @@ -88,9 +88,9 @@ The following arguments are supported: * `host_group_id` - (Optional) The fully qualified resource ID of the Dedicated Host Group to provision virtual machines from. Changing this forces a new resource to be created. -* `kubelet_config` - (Optional) A `kubelet_config` block as defined below. Changing this property requires specifying `temporary_name_for_rotation`. +* `kubelet_config` - (Optional) A `kubelet_config` block as defined below. Changing this requires specifying `temporary_name_for_rotation`. -* `linux_os_config` - (Optional) A `linux_os_config` block as defined below. Changing this property requires specifying `temporary_name_for_rotation`. +* `linux_os_config` - (Optional) A `linux_os_config` block as defined below. Changing this requires specifying `temporary_name_for_rotation`. * `fips_enabled` - (Optional) Should the nodes in this Node Pool have Federal Information Processing Standard enabled? Changing this property requires specifying `temporary_name_for_rotation`. @@ -124,7 +124,7 @@ The following arguments are supported: * `os_sku` - (Optional) Specifies the OS SKU used by the agent pool. Possible values are `AzureLinux`, `Ubuntu`, `Windows2019` and `Windows2022`. If not specified, the default is `Ubuntu` if OSType=Linux or `Windows2019` if OSType=Windows. And the default Windows OSSKU will be changed to `Windows2022` after Windows2019 is deprecated. Changing this from `AzureLinux` or `Ubuntu` to `AzureLinux` or `Ubuntu` will not replace the resource, otherwise it forces a new resource to be created. -* `os_type` - (Optional) The Operating System which should be used for this Node Pool. Changing this property requires specifying `temporary_name_for_rotation`. Possible values are `Linux` and `Windows`. Defaults to `Linux`. +* `os_type` - (Optional) The Operating System which should be used for this Node Pool. Changing this forces a new resource to be created. Possible values are `Linux` and `Windows`. Defaults to `Linux`. * `priority` - (Optional) The Priority for Virtual Machines within the Virtual Machine Scale Set that powers this Node Pool. Possible values are `Regular` and `Spot`. Defaults to `Regular`. Changing this forces a new resource to be created. @@ -144,6 +144,8 @@ The following arguments are supported: * `scale_down_mode` - (Optional) Specifies how the node pool should deal with scaled-down nodes. Allowed values are `Delete` and `Deallocate`. Defaults to `Delete`. +* `temporary_name_for_rotation` - (Optional) Specifies the name of the temporary node pool used to cycle node pool when one of the relevant properties are updated. + * `ultra_ssd_enabled` - (Optional) Used to specify whether the UltraSSD is enabled in the Node Pool. Defaults to `false`. See [the documentation](https://docs.microsoft.com/azure/aks/use-ultra-disks) for more information. Changing this property requires specifying `temporary_name_for_rotation`. * `upgrade_settings` - (Optional) A `upgrade_settings` block as documented below. @@ -158,7 +160,7 @@ The following arguments are supported: ~> **Note:** WebAssembly System Interface node pools are in Public Preview - more information and details on how to opt into the preview can be found in [this article](https://docs.microsoft.com/azure/aks/use-wasi-node-pools) -* `zones` - (Optional) Specifies a list of Availability Zones in which this Kubernetes Cluster Node Pool should be located. Changing this forces a new Kubernetes Cluster Node Pool to be created. +* `zones` - (Optional) Specifies a list of Availability Zones in which this Kubernetes Cluster Node Pool should be located. Changing this property requires specifying `temporary_name_for_rotation`. --- @@ -186,7 +188,7 @@ A `kubelet_config` block supports the following: * `container_log_max_size_mb` - (Optional) Specifies the maximum size (e.g. 10MB) of container log file before it is rotated. -* `cpu_cfs_quota_enabled` - (Optional) Is CPU CFS quota enforcement for containers enabled? +* `cpu_cfs_quota_enabled` - (Optional) Is CPU CFS quota enforcement for containers enabled? Defaults to `true`. * `cpu_cfs_quota_period` - (Optional) Specifies the CPU CFS quota period value. @@ -204,13 +206,13 @@ A `kubelet_config` block supports the following: A `linux_os_config` block supports the following: -* `swap_file_size_mb` - (Optional) Specifies the size of swap file on each node in MB. Changing this forces a new resource to be created. +* `swap_file_size_mb` - (Optional) Specifies the size of swap file on each node in MB. -* `sysctl_config` - (Optional) A `sysctl_config` block as defined below. Changing this forces a new resource to be created. +* `sysctl_config` - (Optional) A `sysctl_config` block as defined below. -* `transparent_huge_page_defrag` - (Optional) specifies the defrag configuration for Transparent Huge Page. Possible values are `always`, `defer`, `defer+madvise`, `madvise` and `never`. Changing this forces a new resource to be created. +* `transparent_huge_page_defrag` - (Optional) specifies the defrag configuration for Transparent Huge Page. Possible values are `always`, `defer`, `defer+madvise`, `madvise` and `never`. -* `transparent_huge_page_enabled` - (Optional) Specifies the Transparent Huge Page enabled configuration. Possible values are `always`, `madvise` and `never`. Changing this forces a new resource to be created. +* `transparent_huge_page_enabled` - (Optional) Specifies the Transparent Huge Page enabled configuration. Possible values are `always`, `madvise` and `never`. --- @@ -238,63 +240,63 @@ A `sysctl_config` block supports the following: ~> For more information, please refer to [Linux Kernel Doc](https://www.kernel.org/doc/html/latest/admin-guide/sysctl/index.html). -* `fs_aio_max_nr` - (Optional) The sysctl setting fs.aio-max-nr. Must be between `65536` and `6553500`. Changing this forces a new resource to be created. +* `fs_aio_max_nr` - (Optional) The sysctl setting fs.aio-max-nr. Must be between `65536` and `6553500`. -* `fs_file_max` - (Optional) The sysctl setting fs.file-max. Must be between `8192` and `12000500`. Changing this forces a new resource to be created. +* `fs_file_max` - (Optional) The sysctl setting fs.file-max. Must be between `8192` and `12000500`. -* `fs_inotify_max_user_watches` - (Optional) The sysctl setting fs.inotify.max_user_watches. Must be between `781250` and `2097152`. Changing this forces a new resource to be created. +* `fs_inotify_max_user_watches` - (Optional) The sysctl setting fs.inotify.max_user_watches. Must be between `781250` and `2097152`. -* `fs_nr_open` - (Optional) The sysctl setting fs.nr_open. Must be between `8192` and `20000500`. Changing this forces a new resource to be created. +* `fs_nr_open` - (Optional) The sysctl setting fs.nr_open. Must be between `8192` and `20000500`. -* `kernel_threads_max` - (Optional) The sysctl setting kernel.threads-max. Must be between `20` and `513785`. Changing this forces a new resource to be created. +* `kernel_threads_max` - (Optional) The sysctl setting kernel.threads-max. Must be between `20` and `513785`. -* `net_core_netdev_max_backlog` - (Optional) The sysctl setting net.core.netdev_max_backlog. Must be between `1000` and `3240000`. Changing this forces a new resource to be created. +* `net_core_netdev_max_backlog` - (Optional) The sysctl setting net.core.netdev_max_backlog. Must be between `1000` and `3240000`. -* `net_core_optmem_max` - (Optional) The sysctl setting net.core.optmem_max. Must be between `20480` and `4194304`. Changing this forces a new resource to be created. +* `net_core_optmem_max` - (Optional) The sysctl setting net.core.optmem_max. Must be between `20480` and `4194304`. -* `net_core_rmem_default` - (Optional) The sysctl setting net.core.rmem_default. Must be between `212992` and `134217728`. Changing this forces a new resource to be created. +* `net_core_rmem_default` - (Optional) The sysctl setting net.core.rmem_default. Must be between `212992` and `134217728`. -* `net_core_rmem_max` - (Optional) The sysctl setting net.core.rmem_max. Must be between `212992` and `134217728`. Changing this forces a new resource to be created. +* `net_core_rmem_max` - (Optional) The sysctl setting net.core.rmem_max. Must be between `212992` and `134217728`. -* `net_core_somaxconn` - (Optional) The sysctl setting net.core.somaxconn. Must be between `4096` and `3240000`. Changing this forces a new resource to be created. +* `net_core_somaxconn` - (Optional) The sysctl setting net.core.somaxconn. Must be between `4096` and `3240000`. -* `net_core_wmem_default` - (Optional) The sysctl setting net.core.wmem_default. Must be between `212992` and `134217728`. Changing this forces a new resource to be created. +* `net_core_wmem_default` - (Optional) The sysctl setting net.core.wmem_default. Must be between `212992` and `134217728`. -* `net_core_wmem_max` - (Optional) The sysctl setting net.core.wmem_max. Must be between `212992` and `134217728`. Changing this forces a new resource to be created. +* `net_core_wmem_max` - (Optional) The sysctl setting net.core.wmem_max. Must be between `212992` and `134217728`. -* `net_ipv4_ip_local_port_range_max` - (Optional) The sysctl setting net.ipv4.ip_local_port_range max value. Must be between `32768` and `65535`. Changing this forces a new resource to be created. +* `net_ipv4_ip_local_port_range_max` - (Optional) The sysctl setting net.ipv4.ip_local_port_range max value. Must be between `32768` and `65535`. -* `net_ipv4_ip_local_port_range_min` - (Optional) The sysctl setting net.ipv4.ip_local_port_range min value. Must be between `1024` and `60999`. Changing this forces a new resource to be created. +* `net_ipv4_ip_local_port_range_min` - (Optional) The sysctl setting net.ipv4.ip_local_port_range min value. Must be between `1024` and `60999`. -* `net_ipv4_neigh_default_gc_thresh1` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh1. Must be between `128` and `80000`. Changing this forces a new resource to be created. +* `net_ipv4_neigh_default_gc_thresh1` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh1. Must be between `128` and `80000`. -* `net_ipv4_neigh_default_gc_thresh2` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh2. Must be between `512` and `90000`. Changing this forces a new resource to be created. +* `net_ipv4_neigh_default_gc_thresh2` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh2. Must be between `512` and `90000`. -* `net_ipv4_neigh_default_gc_thresh3` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh3. Must be between `1024` and `100000`. Changing this forces a new resource to be created. +* `net_ipv4_neigh_default_gc_thresh3` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh3. Must be between `1024` and `100000`. -* `net_ipv4_tcp_fin_timeout` - (Optional) The sysctl setting net.ipv4.tcp_fin_timeout. Must be between `5` and `120`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_fin_timeout` - (Optional) The sysctl setting net.ipv4.tcp_fin_timeout. Must be between `5` and `120`. -* `net_ipv4_tcp_keepalive_intvl` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_intvl. Must be between `10` and `90`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_keepalive_intvl` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_intvl. Must be between `10` and `90`. -* `net_ipv4_tcp_keepalive_probes` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_probes. Must be between `1` and `15`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_keepalive_probes` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_probes. Must be between `1` and `15`. -* `net_ipv4_tcp_keepalive_time` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_time. Must be between `30` and `432000`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_keepalive_time` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_time. Must be between `30` and `432000`. -* `net_ipv4_tcp_max_syn_backlog` - (Optional) The sysctl setting net.ipv4.tcp_max_syn_backlog. Must be between `128` and `3240000`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_max_syn_backlog` - (Optional) The sysctl setting net.ipv4.tcp_max_syn_backlog. Must be between `128` and `3240000`. -* `net_ipv4_tcp_max_tw_buckets` - (Optional) The sysctl setting net.ipv4.tcp_max_tw_buckets. Must be between `8000` and `1440000`. Changing this forces a new resource to be created. +* `net_ipv4_tcp_max_tw_buckets` - (Optional) The sysctl setting net.ipv4.tcp_max_tw_buckets. Must be between `8000` and `1440000`. -* `net_ipv4_tcp_tw_reuse` - (Optional) Is sysctl setting net.ipv4.tcp_tw_reuse enabled? Changing this forces a new resource to be created. +* `net_ipv4_tcp_tw_reuse` - (Optional) Is sysctl setting net.ipv4.tcp_tw_reuse enabled? -* `net_netfilter_nf_conntrack_buckets` - (Optional) The sysctl setting net.netfilter.nf_conntrack_buckets. Must be between `65536` and `524288`. Changing this forces a new resource to be created. +* `net_netfilter_nf_conntrack_buckets` - (Optional) The sysctl setting net.netfilter.nf_conntrack_buckets. Must be between `65536` and `524288`. -* `net_netfilter_nf_conntrack_max` - (Optional) The sysctl setting net.netfilter.nf_conntrack_max. Must be between `131072` and `2097152`. Changing this forces a new resource to be created. +* `net_netfilter_nf_conntrack_max` - (Optional) The sysctl setting net.netfilter.nf_conntrack_max. Must be between `131072` and `2097152`. -* `vm_max_map_count` - (Optional) The sysctl setting vm.max_map_count. Must be between `65530` and `262144`. Changing this forces a new resource to be created. +* `vm_max_map_count` - (Optional) The sysctl setting vm.max_map_count. Must be between `65530` and `262144`. -* `vm_swappiness` - (Optional) The sysctl setting vm.swappiness. Must be between `0` and `100`. Changing this forces a new resource to be created. +* `vm_swappiness` - (Optional) The sysctl setting vm.swappiness. Must be between `0` and `100`. -* `vm_vfs_cache_pressure` - (Optional) The sysctl setting vm.vfs_cache_pressure. Must be between `0` and `100`. Changing this forces a new resource to be created. +* `vm_vfs_cache_pressure` - (Optional) The sysctl setting vm.vfs_cache_pressure. Must be between `0` and `100`. --- @@ -302,7 +304,7 @@ A `upgrade_settings` block supports the following: * `drain_timeout_in_minutes` - (Optional) The amount of time in minutes to wait on eviction of pods and graceful termination per node. This eviction wait time honors waiting on pod disruption budgets. If this time is exceeded, the upgrade fails. Unsetting this after configuring it will force a new resource to be created. -* `node_soak_duration_in_minutes` - (Optional) The amount of time in minutes to wait after draining a node and before reimaging and moving on to next node. Defaults to `0`. +* `node_soak_duration_in_minutes` - (Optional) The amount of time in minutes to wait after draining a node and before reimaging and moving on to next node. * `max_surge` - (Required) The maximum number or percentage of nodes which will be added to the Node Pool size during an upgrade. From 71939b0085d6f98079ce63bfd46261803fde41f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 17:18:21 -0300 Subject: [PATCH 08/13] Update pointer's function. --- .../kubernetes_cluster_node_pool_resource.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 7dd0ccf00b2f..67bd94af66d2 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -719,11 +719,11 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("fips_enabled") { - props.EnableFIPS = utils.Bool(d.Get("fips_enabled").(bool)) + props.EnableFIPS = pointer.To(d.Get("fips_enabled").(bool)) } if d.HasChange("host_encryption_enabled") { - props.EnableEncryptionAtHost = utils.Bool(d.Get("host_encryption_enabled").(bool)) + props.EnableEncryptionAtHost = pointer.To(d.Get("host_encryption_enabled").(bool)) } if d.HasChange("kubelet_config") { @@ -750,7 +750,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("max_pods") { - props.MaxPods = utils.Int64(int64(d.Get("max_pods").(int))) + props.MaxPods = pointer.To(int64(d.Get("max_pods").(int))) } if d.HasChange("mode") { @@ -767,11 +767,11 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("node_public_ip_enabled") { - props.EnableNodePublicIP = utils.Bool(d.Get("node_public_ip_enabled").(bool)) + props.EnableNodePublicIP = pointer.To(d.Get("node_public_ip_enabled").(bool)) } if d.HasChange("node_public_ip_prefix_id") { - props.NodePublicIPPrefixID = utils.String(d.Get("node_public_ip_prefix_id").(string)) + props.NodePublicIPPrefixID = pointer.To(d.Get("node_public_ip_prefix_id").(string)) } if d.HasChange("orchestrator_version") { @@ -803,7 +803,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("os_disk_size_gb") { - props.OsDiskSizeGB = utils.Int64(int64(d.Get("os_disk_size_gb").(int))) + props.OsDiskSizeGB = pointer.To(int64(d.Get("os_disk_size_gb").(int))) } if d.HasChange("os_sku") { @@ -811,11 +811,11 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("pod_subnet_id") { - props.PodSubnetID = utils.String(d.Get("pod_subnet_id").(string)) + props.PodSubnetID = pointer.To(d.Get("pod_subnet_id").(string)) } if d.HasChange("ultra_ssd_enabled") { - props.EnableUltraSSD = utils.Bool(d.Get("ultra_ssd_enabled").(bool)) + props.EnableUltraSSD = pointer.To(d.Get("ultra_ssd_enabled").(bool)) } if d.HasChange("upgrade_settings") { @@ -830,12 +830,12 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int if d.HasChange("snapshot_id") { props.CreationData = &agentpools.CreationData{ - SourceResourceId: utils.String(d.Get("snapshot_id").(string)), + SourceResourceId: pointer.To(d.Get("snapshot_id").(string)), } } if d.HasChange("vm_size") { - props.VMSize = utils.String(d.Get("vm_size").(string)) + props.VMSize = pointer.To(d.Get("vm_size").(string)) } if d.HasChange("vnet_subnet_id") { @@ -846,7 +846,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int return err } if subnetID != nil { - props.VnetSubnetID = utils.String(subnetID.ID()) + props.VnetSubnetID = pointer.To(subnetID.ID()) } } } From 2385b1b5b75c091c695ea3a9e68af3fa6ac2f304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 17:23:56 -0300 Subject: [PATCH 09/13] Improving subnet assignment --- .../containers/kubernetes_cluster_node_pool_resource.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 67bd94af66d2..c051c481126e 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -839,15 +839,12 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("vnet_subnet_id") { - var subnetID *commonids.SubnetId if subnetIDValue, ok := d.GetOk("vnet_subnet_id"); ok { - subnetID, err = commonids.ParseSubnetID(subnetIDValue.(string)) + subnetID, err := commonids.ParseSubnetID(subnetIDValue.(string)) if err != nil { return err } - if subnetID != nil { - props.VnetSubnetID = pointer.To(subnetID.ID()) - } + props.VnetSubnetID = pointer.To(subnetID.ID()) } } From 67c5bcc8f1e478f35beec851996eb631ee222373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 17:32:49 -0300 Subject: [PATCH 10/13] Fixing zones not being updated when value was set to null. --- .../containers/kubernetes_cluster_node_pool_resource.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index c051c481126e..c51225b264d1 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -867,9 +867,7 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int if d.HasChange("zones") { zones := zones.ExpandUntyped(d.Get("zones").(*schema.Set).List()) - if len(zones) > 0 { - props.AvailabilityZones = &zones - } + props.AvailabilityZones = &zones } // validate the auto-scale fields are both set/unset to prevent a continual diff From b3ff967635b69311aa82f0a0cf87c4ad161aa4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 18:32:28 -0300 Subject: [PATCH 11/13] Fixing assigment when value is null --- .../kubernetes_cluster_node_pool_resource.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index c51225b264d1..281fb6ebf459 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -727,22 +727,21 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int } if d.HasChange("kubelet_config") { - if kubeletConfig := d.Get("kubelet_config").([]interface{}); len(kubeletConfig) > 0 { - props.KubeletConfig = expandAgentPoolKubeletConfig(kubeletConfig) - } + kubeletConfigRaw := d.Get("kubelet_config").([]interface{}) + props.KubeletConfig = expandAgentPoolKubeletConfig(kubeletConfigRaw) } if d.HasChange("linux_os_config") { - if linuxOSConfig := d.Get("linux_os_config").([]interface{}); len(linuxOSConfig) > 0 { - if d.Get("os_type").(string) != string(managedclusters.OSTypeLinux) { - return fmt.Errorf("`linux_os_config` can only be configured when `os_type` is set to `linux`") - } - linuxOSConfig, err := expandAgentPoolLinuxOSConfig(linuxOSConfig) - if err != nil { - return err - } - props.LinuxOSConfig = linuxOSConfig + linuxOSConfigRaw := d.Get("linux_os_config").([]interface{}) + if d.Get("os_type").(string) != string(managedclusters.OSTypeLinux) { + return fmt.Errorf("`linux_os_config` can only be configured when `os_type` is set to `linux`") } + linuxOSConfig, err := expandAgentPoolLinuxOSConfig(linuxOSConfigRaw) + if err != nil { + return err + } + props.LinuxOSConfig = linuxOSConfig + } if d.HasChange("max_count") || enableAutoScaling { From cbdf94ed12927633f4f2de6ed86811e32277dcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 18:35:34 -0300 Subject: [PATCH 12/13] Restoring files lose on merge. --- ...inverificationfailureinfodetailsinlined.go | 10 +++ ...tewaybackendaddresspoolpropertiesformat.go | 10 +++ ...ewayprivateendpointconnectionproperties.go | 11 +++ ...gurationprivatelinkconnectionproperties.go | 10 +++ ...ecrossconnectionslistroutestablesummary.go | 89 +++++++++++++++++++ ...agereffectiveconnectivityconfigurations.go | 59 ++++++++++++ ...tiveconnectivityconfigurationlistresult.go | 9 ++ ...sdatabasenationalcharactersetproperties.go | 8 ++ 8 files changed, 206 insertions(+) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go new file mode 100644 index 000000000000..1a9643ffafab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsInlined struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 000000000000..508dc9994b46 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go new file mode 100644 index 000000000000..19f24417e8bc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 000000000000..fc79de05a6f0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go new file mode 100644 index 000000000000..64acafa8284e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go @@ -0,0 +1,89 @@ +package expressroutecrossconnectionroutetablesummary + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionsListRoutesTableSummaryOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCrossConnectionRoutesTableSummary +} + +type ExpressRouteCrossConnectionsListRoutesTableSummaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCrossConnectionRoutesTableSummary +} + +type ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCrossConnectionsListRoutesTableSummary ... +func (c ExpressRouteCrossConnectionRouteTableSummaryClient) ExpressRouteCrossConnectionsListRoutesTableSummary(ctx context.Context, id PeeringRouteTablesSummaryId) (result ExpressRouteCrossConnectionsListRoutesTableSummaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCrossConnectionsListRoutesTableSummaryThenPoll performs ExpressRouteCrossConnectionsListRoutesTableSummary then polls until it's completed +func (c ExpressRouteCrossConnectionRouteTableSummaryClient) ExpressRouteCrossConnectionsListRoutesTableSummaryThenPoll(ctx context.Context, id PeeringRouteTablesSummaryId) error { + result, err := c.ExpressRouteCrossConnectionsListRoutesTableSummary(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCrossConnectionsListRoutesTableSummary: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCrossConnectionsListRoutesTableSummary: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go new file mode 100644 index 000000000000..64233acc1956 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go @@ -0,0 +1,59 @@ +package networkmanagereffectiveconnectivityconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkManagerEffectiveConnectivityConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerEffectiveConnectivityConfigurationListResult +} + +// ListNetworkManagerEffectiveConnectivityConfigurations ... +func (c NetworkManagerEffectiveConnectivityConfigurationClient) ListNetworkManagerEffectiveConnectivityConfigurations(ctx context.Context, id commonids.VirtualNetworkId, input QueryRequestOptions) (result ListNetworkManagerEffectiveConnectivityConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listNetworkManagerEffectiveConnectivityConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerEffectiveConnectivityConfigurationListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go new file mode 100644 index 000000000000..566b11872ea4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-03-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go @@ -0,0 +1,9 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerEffectiveConnectivityConfigurationListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]EffectiveConnectivityConfiguration `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go new file mode 100644 index 000000000000..f55ed168e3f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go @@ -0,0 +1,8 @@ +package autonomousdatabasenationalcharactersets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseNationalCharacterSetProperties struct { + CharacterSet string `json:"characterSet"` +} From 51cb2635009845b67f2068ee9ab21ab7a710ab40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Fern=C3=A1ndez?= Date: Thu, 12 Dec 2024 18:53:25 -0300 Subject: [PATCH 13/13] Linting --- .../containers/kubernetes_cluster_node_pool_resource.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 281fb6ebf459..ee2a399ee906 100644 --- a/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -741,7 +741,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int return err } props.LinuxOSConfig = linuxOSConfig - } if d.HasChange("max_count") || enableAutoScaling { @@ -976,7 +975,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int log.Printf("[DEBUG] Cycled Node Pool..") } else { - log.Printf("[DEBUG] Updating existing %s..", *id) err = client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model) if err != nil {