Skip to content

Commit

Permalink
azurerm_kubernetes_cluster - fix issue where`maintenance_window_aut…
Browse files Browse the repository at this point in the history
…o_upgrade`/`maintenance_window_auto_upgrade`/`maintenance_window_node_os ` might not be read into state (#26915)
  • Loading branch information
hqhqhqhqhqhqhqhqhqhqhq authored Nov 1, 2024
1 parent ecede1a commit 35a4a02
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2813,24 +2813,30 @@ func resourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{})
return fmt.Errorf("setting `kube_config`: %+v", err)
}

var maintenanceWindow interface{}
maintenanceConfigurationsClient := meta.(*clients.Client).Containers.MaintenanceConfigurationsClient
maintenanceId := maintenanceconfigurations.NewMaintenanceConfigurationID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, "default")
configResp, _ := maintenanceConfigurationsClient.Get(ctx, maintenanceId)
if configurationBody := configResp.Model; configurationBody != nil && configurationBody.Properties != nil {
d.Set("maintenance_window", flattenKubernetesClusterMaintenanceConfigurationDefault(configurationBody.Properties))
maintenanceWindow = flattenKubernetesClusterMaintenanceConfigurationDefault(configurationBody.Properties)
}
d.Set("maintenance_window", maintenanceWindow)

var maintenanceWindowAutoUpgrade interface{}
maintenanceId = maintenanceconfigurations.NewMaintenanceConfigurationID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, "aksManagedAutoUpgradeSchedule")
configResp, _ = maintenanceConfigurationsClient.Get(ctx, maintenanceId)
if configurationBody := configResp.Model; configurationBody != nil && configurationBody.Properties != nil && configurationBody.Properties.MaintenanceWindow != nil {
d.Set("maintenance_window_auto_upgrade", flattenKubernetesClusterMaintenanceConfiguration(configurationBody.Properties.MaintenanceWindow))
maintenanceWindowAutoUpgrade = flattenKubernetesClusterMaintenanceConfiguration(configurationBody.Properties.MaintenanceWindow)
}
d.Set("maintenance_window_auto_upgrade", maintenanceWindowAutoUpgrade)

var maintenanceWindowNodeOS interface{}
maintenanceId = maintenanceconfigurations.NewMaintenanceConfigurationID(id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, "aksManagedNodeOSUpgradeSchedule")
configResp, _ = maintenanceConfigurationsClient.Get(ctx, maintenanceId)
if configurationBody := configResp.Model; configurationBody != nil && configurationBody.Properties != nil && configurationBody.Properties.MaintenanceWindow != nil {
d.Set("maintenance_window_node_os", flattenKubernetesClusterMaintenanceConfiguration(configurationBody.Properties.MaintenanceWindow))
maintenanceWindowNodeOS = flattenKubernetesClusterMaintenanceConfiguration(configurationBody.Properties.MaintenanceWindow)
}
d.Set("maintenance_window_node_os", maintenanceWindowNodeOS)

if err := tags.FlattenAndSet(d, model.Tags); err != nil {
return fmt.Errorf("setting `tags`: %+v", err)
Expand Down

0 comments on commit 35a4a02

Please sign in to comment.