Skip to content

Commit 3c56207

Browse files
fix failing remove (#5156) (#3600)
Signed-off-by: Modular Magician <[email protected]>
1 parent b1d9d7b commit 3c56207

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

.changelog/5156.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
Container: fixed a bug in failing to remove `maintenance_exclusion` on `google_container_cluster`
3+
```

google-beta/resource_container_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,7 @@ func expandMaintenancePolicy(d *schema.ResourceData, meta interface{}) *containe
30113011
}
30123012
maintenancePolicy := l[0].(map[string]interface{})
30133013

3014-
if maintenanceExclusions, ok := maintenancePolicy["maintenance_exclusion"]; ok && len(maintenanceExclusions.(*schema.Set).List()) > 0 {
3014+
if maintenanceExclusions, ok := maintenancePolicy["maintenance_exclusion"]; ok {
30153015
for k := range exclusions {
30163016
delete(exclusions, k)
30173017
}

google-beta/resource_container_cluster_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,47 @@ func TestAccContainerCluster_withMaintenanceExclusionWindow(t *testing.T) {
14031403
})
14041404
}
14051405

1406+
func TestAccContainerCluster_deleteExclusionWindow(t *testing.T) {
1407+
t.Parallel()
1408+
cluster := fmt.Sprintf("tf-test-cluster-%s", randString(t, 10))
1409+
resourceName := "google_container_cluster.with_maintenance_exclusion_window"
1410+
1411+
vcrTest(t, resource.TestCase{
1412+
PreCheck: func() { testAccPreCheck(t) },
1413+
Providers: testAccProviders,
1414+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
1415+
Steps: []resource.TestStep{
1416+
{
1417+
Config: testAccContainerCluster_withExclusion_DailyMaintenanceWindow(cluster, "2020-01-01T00:00:00Z", "2020-01-02T00:00:00Z"),
1418+
},
1419+
{
1420+
ResourceName: resourceName,
1421+
ImportStateIdPrefix: "us-central1-a/",
1422+
ImportState: true,
1423+
ImportStateVerify: true,
1424+
},
1425+
{
1426+
Config: testAccContainerCluster_withExclusion_RecurringMaintenanceWindow(cluster, "2019-01-01T00:00:00Z", "2019-01-02T00:00:00Z", "2019-05-01T00:00:00Z", "2019-05-02T00:00:00Z"),
1427+
},
1428+
{
1429+
ResourceName: resourceName,
1430+
ImportStateIdPrefix: "us-central1-a/",
1431+
ImportState: true,
1432+
ImportStateVerify: true,
1433+
},
1434+
{
1435+
Config: testAccContainerCluster_withExclusion_NoMaintenanceWindow(cluster, "2020-01-01T00:00:00Z", "2020-01-02T00:00:00Z"),
1436+
},
1437+
{
1438+
ResourceName: resourceName,
1439+
ImportStateIdPrefix: "us-central1-a/",
1440+
ImportState: true,
1441+
ImportStateVerify: true,
1442+
},
1443+
},
1444+
})
1445+
}
1446+
14061447
func TestAccContainerCluster_withIPAllocationPolicy_existingSecondaryRanges(t *testing.T) {
14071448
t.Parallel()
14081449

@@ -3697,6 +3738,25 @@ resource "google_container_cluster" "with_maintenance_exclusion_window" {
36973738
`, clusterName, w1startTime, w1endTime, w1startTime, w1endTime, w2startTime, w2endTime)
36983739
}
36993740

3741+
func testAccContainerCluster_withExclusion_NoMaintenanceWindow(clusterName string, w1startTime, w1endTime string) string {
3742+
3743+
return fmt.Sprintf(`
3744+
resource "google_container_cluster" "with_maintenance_exclusion_window" {
3745+
name = "%s"
3746+
location = "us-central1-a"
3747+
initial_node_count = 1
3748+
3749+
maintenance_policy {
3750+
recurring_window {
3751+
start_time = "%s"
3752+
end_time = "%s"
3753+
recurrence = "FREQ=DAILY"
3754+
}
3755+
}
3756+
}
3757+
`, clusterName, w1startTime, w1endTime)
3758+
}
3759+
37003760
func testAccContainerCluster_withExclusion_DailyMaintenanceWindow(clusterName string, w1startTime, w1endTime string) string {
37013761

37023762
return fmt.Sprintf(`

0 commit comments

Comments
 (0)