Skip to content

Commit

Permalink
azurerm_kubernetes_cluster - fix panic in service_mesh_profile in…
Browse files Browse the repository at this point in the history
… 4.0 mode (#26783)

* fix panic in aks data source

* remove Mariner sku

* remove a redundant test and fix condition for skipping tests not applicable in 4.0

* remove test step that no longer applies in 4.0
  • Loading branch information
stephybun authored Jul 25, 2024
1 parent f00bbe2 commit 4b29491
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,6 @@ resource "azurerm_kubernetes_cluster" "test" {
azure_active_directory_role_based_access_control {
tenant_id = var.tenant_id
managed = true
}
}
`, tenantId, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
Expand Down
15 changes: 11 additions & 4 deletions internal/services/containers/kubernetes_cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource {
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{

"blob_driver_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
Expand Down Expand Up @@ -716,6 +715,13 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource {
},
},
},
"revisions": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},
},
},
},
Expand All @@ -725,6 +731,10 @@ func dataSourceKubernetesCluster() *pluginsdk.Resource {
}

if !features.FourPointOhBeta() {
// adding revisions to the resource is a breaking change, MSFT would like the corresponding change in data source to happen at the same time
serviceMeshProfile := resource.Schema["service_mesh_profile"].Elem.(*pluginsdk.Resource).SchemaMap()
delete(serviceMeshProfile, "revisions")

resource.Schema["agent_pool_profile"].Elem.(*pluginsdk.Resource).Schema["enable_auto_scaling"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Computed: true,
Expand Down Expand Up @@ -1350,9 +1360,6 @@ func flattenKubernetesClusterDataSourceAzureActiveDirectoryRoleBasedAccessContro

result := map[string]interface{}{
"admin_group_object_ids": adminGroupObjectIds,
"client_app_id": clientAppId,
"managed": managed,
"server_app_id": serverAppId,
"tenant_id": tenantId,
"azure_rbac_enabled": azureRbacEnabled,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,38 +841,6 @@ func TestAccKubernetesCluster_osSkuUpdate(t *testing.T) {
})
}

func TestAccKubernetesCluster_osSkuCycleNodePool(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.osSkuCycleNodePool(data, "Ubuntu"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("default_node_pool.0.os_sku").HasValue("Ubuntu"),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.osSkuCycleNodePool(data, "Mariner"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("default_node_pool.0.os_sku").HasValue("Mariner"),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.osSkuCycleNodePool(data, "AzureLinux"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("default_node_pool.0.os_sku").HasValue("AzureLinux"),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
})
}

func TestAccKubernetesCluster_microsoftDefender(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}
Expand Down Expand Up @@ -984,7 +952,7 @@ func TestAccKubernetesCluster_webAppRoutingWithMultipleDnsZone(t *testing.T) {
}

func TestAccKubernetesCluster_webAppRouting(t *testing.T) {
if !features.FourPointOhBeta() {
if features.FourPointOhBeta() {
t.Skip("Skipping test in 4.0 as `dns_zone_id` is removed")
}
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
Expand Down Expand Up @@ -1025,7 +993,7 @@ func TestAccKubernetesCluster_webAppRouting(t *testing.T) {
}

func TestAccKubernetesCluster_webAppRoutingPrivateDNS(t *testing.T) {
if !features.FourPointOhBeta() {
if features.FourPointOhBeta() {
t.Skip("Skipping test in 4.0 as `dns_zone_id` is removed")
}
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
Expand Down Expand Up @@ -1947,7 +1915,7 @@ resource "azurerm_kubernetes_cluster" "test" {
node_count = 1
vm_size = "Standard_D2s_v3"
message_of_the_day = "daily message"
os_sku = "Mariner"
os_sku = "AzureLinux"
workload_runtime = "KataMshvVmIsolation"
upgrade_settings {
max_surge = "10%%"
Expand Down Expand Up @@ -3076,41 +3044,6 @@ resource "azurerm_kubernetes_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, osSKu)
}

func (KubernetesClusterResource) osSkuCycleNodePool(data acceptance.TestData, osSKu string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-aks-%d"
location = "%s"
}
resource "azurerm_kubernetes_cluster" "test" {
name = "acctestaks%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_prefix = "acctestaks%d"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2s_v3"
os_sku = "%s"
temporary_name_for_rotation = "temp"
upgrade_settings {
max_surge = "10%%"
}
}
identity {
type = "SystemAssigned"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, osSKu)
}

func (KubernetesClusterResource) oidcIssuer(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ resource "azurerm_route_table" "test" {
disable_bgp_route_propagation = false
route {
name = "internal"
address_prefix = azurerm_virtual_network.test.address_space[0]
address_prefix = tolist(azurerm_virtual_network.test.address_space)[0]
next_hop_type = "VnetLocal"
}
route {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ func TestAccKubernetesCluster_cycleSystemNodePool(t *testing.T) {
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.updateOsSku(data, "Mariner"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.updateZones(data, "Standard_D2ads_v5", "[1,2,3]"),
Check: acceptance.ComposeTestCheckFunc(
Expand Down Expand Up @@ -848,56 +841,6 @@ resource "azurerm_kubernetes_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, osDiskType, osDiskSize)
}

func (KubernetesClusterResource) updateOsSku(data acceptance.TestData, osSku string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-aks-%d"
location = "%s"
}
resource "azurerm_kubernetes_cluster" "test" {
name = "acctestaks%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_prefix = "acctestaks%d"
default_node_pool {
name = "default"
temporary_name_for_rotation = "temp"
node_count = 1
os_sku = "%s"
vm_size = "Standard_D2ads_v5"
kubelet_config {
pod_max_pid = 12346
}
linux_os_config {
sysctl_config {
vm_swappiness = 40
}
}
upgrade_settings {
max_surge = "10%%"
}
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "standard"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, osSku)
}

func (KubernetesClusterResource) addAgentConfig(data acceptance.TestData, numberOfAgents int) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit 4b29491

Please sign in to comment.