Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed maintenance_exclusion deletion #8589

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4541.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: Fixed failure in deleting `maintenance_exclusion` for `google_container_cluster`
```
3 changes: 3 additions & 0 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,9 @@ func expandMaintenancePolicy(d *schema.ResourceData, meta interface{}) *containe
maintenancePolicy := l[0].(map[string]interface{})

if maintenanceExclusions, ok := maintenancePolicy["maintenance_exclusion"]; ok && len(maintenanceExclusions.(*schema.Set).List()) > 0 {
for k := range exclusions {
delete(exclusions, k)
}
for _, me := range maintenanceExclusions.(*schema.Set).List() {
exclusion := me.(map[string]interface{})
exclusions[exclusion["exclusion_name"].(string)] = containerBeta.TimeWindow{
Expand Down
11 changes: 3 additions & 8 deletions google/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ func TestAccContainerCluster_withMaintenanceExclusionWindow(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccContainerCluster_withExclusion_DailyMaintenanceWindow(cluster, "2020-01-01T00:00:00Z", "2020-01-02T00:00:00Z", "2020-05-01T00:00:00Z", "2020-05-02T00:00:00Z"),
Config: testAccContainerCluster_withExclusion_DailyMaintenanceWindow(cluster, "2020-01-01T00:00:00Z", "2020-01-02T00:00:00Z"),
},
{
ResourceName: resourceName,
Expand Down Expand Up @@ -2950,7 +2950,7 @@ resource "google_container_cluster" "with_maintenance_exclusion_window" {
`, clusterName, w1startTime, w1endTime, w1startTime, w1endTime, w2startTime, w2endTime)
}

func testAccContainerCluster_withExclusion_DailyMaintenanceWindow(clusterName string, w1startTime, w1endTime, w2startTime, w2endTime string) string {
func testAccContainerCluster_withExclusion_DailyMaintenanceWindow(clusterName string, w1startTime, w1endTime string) string {

return fmt.Sprintf(`
resource "google_container_cluster" "with_maintenance_exclusion_window" {
Expand All @@ -2967,14 +2967,9 @@ resource "google_container_cluster" "with_maintenance_exclusion_window" {
start_time = "%s"
end_time = "%s"
}
maintenance_exclusion {
exclusion_name = "holiday data load"
start_time = "%s"
end_time = "%s"
}
}
}
`, clusterName, w1startTime, w1endTime, w2startTime, w2endTime)
`, clusterName, w1startTime, w1endTime)
}

func testAccContainerCluster_withIPAllocationPolicy_existingSecondaryRanges(containerNetName string, clusterName string) string {
Expand Down