Skip to content

Commit ab49e00

Browse files
authored
Merge pull request #2204 from tonyzhc/feat/add-maintenance-exclusion
Fix invalid maintenance exclusion command
2 parents 8c3db10 + e87f0bb commit ab49e00

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/k8s-integration/cluster.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,6 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
207207
locationArg, locationVal, "--num-nodes", strconv.Itoa(numNodes),
208208
"--quiet", "--machine-type", "n1-standard-2", "--no-enable-autoupgrade"}
209209

210-
// To avoid unexpected GKE maintenance, create a 4-hour maintenance exclusion window.
211-
t := time.Now().UTC()
212-
cmdParams = append(cmdParams, "--maintenance-exclusion",
213-
"start="+t.Format("2006-01-02T15:04:05Z")+
214-
",end="+t.Add(4*time.Hour).Format("2006-01-02T15:04:05Z")+
215-
",name=e2e-test")
216-
217210
if imageType == "win2019" || imageType == "win2022" {
218211
cmdParams = append(cmdParams, "--image-type", "WINDOWS_LTSC_CONTAINERD")
219212
if imageType == "win2019" {
@@ -262,6 +255,17 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
262255
return fmt.Errorf("failed to bring up kubernetes e2e cluster on gke: %v", err.Error())
263256
}
264257

258+
// To avoid unexpected GKE maintenance, create a 4-hour maintenance exclusion window.
259+
startExclusionTime := time.Now().UTC()
260+
cmd = exec.Command("gcloud", "container", "clusters", "update", *gkeTestClusterName, locationArg, locationVal, "--quiet",
261+
"--add-maintenance-exclusion-name", "no-upgrades-during-test",
262+
"--add-maintenance-exclusion-start", startExclusionTime.Format(time.RFC3339),
263+
"--add-maintenance-exclusion-end", startExclusionTime.Add(2*time.Hour).Format(time.RFC3339),
264+
"--add-maintenance-exclusion-scope", "no_upgrades")
265+
if err := runCommand("Updating Cluster with maintenance window", cmd); err != nil {
266+
return fmt.Errorf("failed to update cluster with maintenance window: %w", err)
267+
}
268+
265269
// Because gcloud cannot disable addons on cluster create, the deployment has
266270
// to be disabled on update.
267271
clusterVersion := mustGetKubeClusterVersion()

0 commit comments

Comments
 (0)