Skip to content

Commit 739fbc8

Browse files
danawillowmodular-magician
authored andcommitted
send maintenance_window.hour even if it's zero, since that's a valid value
1 parent 3ec4015 commit 739fbc8

3 files changed

+43
-30
lines changed

google/resource_container_cluster.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,33 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
11061106
d.SetPartial("monitoring_service")
11071107
}
11081108

1109+
if d.HasChange("logging_service") {
1110+
logging := d.Get("logging_service").(string)
1111+
1112+
req := &containerBeta.SetLoggingServiceRequest{
1113+
LoggingService: logging,
1114+
}
1115+
updateF := func() error {
1116+
name := containerClusterFullName(project, location, clusterName)
1117+
op, err := config.clientContainerBeta.Projects.Locations.Clusters.SetLogging(name, req).Do()
1118+
if err != nil {
1119+
return err
1120+
}
1121+
1122+
// Wait until it's updated
1123+
return containerSharedOperationWait(config, op, project, location, "updating GKE logging service", timeoutInMinutes, 2)
1124+
}
1125+
1126+
// Call update serially.
1127+
if err := lockedCall(lockKey, updateF); err != nil {
1128+
return err
1129+
}
1130+
1131+
log.Printf("[INFO] GKE cluster %s: logging service has been updated to %s", d.Id(),
1132+
logging)
1133+
d.SetPartial("logging_service")
1134+
}
1135+
11091136
if d.HasChange("network_policy") {
11101137
np := d.Get("network_policy")
11111138
req := &containerBeta.SetNetworkPolicyRequest{
@@ -1151,33 +1178,6 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
11511178
d.SetPartial("node_pool")
11521179
}
11531180

1154-
if d.HasChange("logging_service") {
1155-
logging := d.Get("logging_service").(string)
1156-
1157-
req := &containerBeta.SetLoggingServiceRequest{
1158-
LoggingService: logging,
1159-
}
1160-
updateF := func() error {
1161-
name := containerClusterFullName(project, location, clusterName)
1162-
op, err := config.clientContainerBeta.Projects.Locations.Clusters.SetLogging(name, req).Do()
1163-
if err != nil {
1164-
return err
1165-
}
1166-
1167-
// Wait until it's updated
1168-
return containerSharedOperationWait(config, op, project, location, "updating GKE logging service", timeoutInMinutes, 2)
1169-
}
1170-
1171-
// Call update serially.
1172-
if err := lockedCall(lockKey, updateF); err != nil {
1173-
return err
1174-
}
1175-
1176-
log.Printf("[INFO] GKE cluster %s: logging service has been updated to %s", d.Id(),
1177-
logging)
1178-
d.SetPartial("logging_service")
1179-
}
1180-
11811181
if d.HasChange("node_config") {
11821182
if d.HasChange("node_config.0.image_type") {
11831183
it := d.Get("node_config.0.image_type").(string)

google/resource_container_cluster_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,18 @@ resource "google_container_cluster" "with_monitoring" {
18251825
}`, clusterName)
18261826
}
18271827

1828+
func testAccContainerCluster_withLoggingAndMonitoring(clusterName, logging, monitoring string) string {
1829+
return fmt.Sprintf(`
1830+
resource "google_container_cluster" "with_logging_monitoring" {
1831+
name = "cluster-test-%s"
1832+
zone = "us-central1-a"
1833+
initial_node_count = 1
1834+
1835+
logging_service = "%s"
1836+
monitoring_service = "%s"
1837+
}`, clusterName, logging, monitoring)
1838+
}
1839+
18281840
func testAccContainerCluster_withNodePoolBasic(cluster, nodePool string) string {
18291841
return fmt.Sprintf(`
18301842
resource "google_container_cluster" "with_node_pool" {

google/resource_sql_database_instance.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,10 @@ func expandMaintenanceWindow(configured []interface{}) *sqladmin.MaintenanceWind
594594

595595
window := configured[0].(map[string]interface{})
596596
return &sqladmin.MaintenanceWindow{
597-
Day: int64(window["day"].(int)),
598-
Hour: int64(window["hour"].(int)),
599-
UpdateTrack: window["update_track"].(string),
597+
Day: int64(window["day"].(int)),
598+
Hour: int64(window["hour"].(int)),
599+
UpdateTrack: window["update_track"].(string),
600+
ForceSendFields: []string{"Hour"},
600601
}
601602
}
602603

0 commit comments

Comments
 (0)