Skip to content

Commit 2b89f55

Browse files
modular-magiciannat-henderson
authored andcommitted
use cluster update for logging/monitoring in beta (#2631)
<!-- This change is generated by MagicModules. --> /cc @danawillow
1 parent 3d4fa23 commit 2b89f55

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
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)

0 commit comments

Comments
 (0)