Skip to content

Commit

Permalink
Merge pull request #3208 from alyssa-sm/update-maintenance.py
Browse files Browse the repository at this point in the history
Update maintenance.py to support additional format
  • Loading branch information
alyssa-sm authored Nov 2, 2024
2 parents f7dabee + aa48f49 commit b1d9411
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/maintenance/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
"upcomingMaintenance.startTimeWindow.earliest," \
"upcomingMaintenance.startTimeWindow.latest," \
"upcomingMaintenance.canReschedule,upcomingMaintenance.type)'"

UPDATED_UPC_MAINT_CMD = "gcloud alpha compute instances list --project={}" \
" --filter='upcomingMaintenance:*' --format='value(name," \
"upcomingMaintenance.latestWindowStartTime," \
"upcomingMaintenance.windowEndTime," \
"upcomingMaintenance.canReschedule,upcomingMaintenance.type)'"

PER_MAINT_CMD = "gcloud alpha compute instances list --project={}" \
" --filter=scheduling.maintenanceInterval:PERIODIC " \
" --format='value(name)'"
Expand Down Expand Up @@ -72,6 +79,9 @@ def get_upcoming_maintenance(project: str) -> List[str]:
err_msg = "Error getting upcoming maintenance list"
res = run_command(UPC_MAINT_CMD.format(project), err_msg)

# Check if all output was received. If length is 3, two of the filters failed since the maintenance output is using new format.
if len(res.stdout.split()) == 3:
res = run_command(UPDATED_UPC_MAINT_CMD.format(project), err_msg)
upc_maint = [x.split() for x in res.stdout.split("\n")[:-1]]

return upc_maint
Expand Down

0 comments on commit b1d9411

Please sign in to comment.