Skip to content

Add VM image rollback script and presubmit failure decision step - #2986

Merged
SalmaSamy merged 4 commits into
masterfrom
image-rollback
Nov 5, 2026
Merged

SalmaSamy merged 4 commits into
masterfrom
image-rollback

Conversation

@SalmaSamy

@SalmaSamy SalmaSamy commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

We build new VM images for the CI agents and test them with the Bazel presubmits before promoting them. Until now, if those presubmits failed, someone had to figure out by hand how to switch the agents back to the previous image.

With this change, a failed image test pauses the pipeline and asks what to do:

  • Roll back to the previous image
  • Ignore the failure and continue (e.g. if it was an infra flake).

Choosing rollback marks the new image as deprecated, so new VMs boot the previous image again, and recreates the affected agents. The new image isn't deleted, and the undo command is printed, so a rollback is easy to reverse.

I tested the decision flow in bazel-testing with a dry-run copy of the rollback step.

@SalmaSamy
SalmaSamy requested a review from a team as a code owner November 2, 2026 18:44
@SalmaSamy
SalmaSamy requested review from Wyverald and ted-xie and removed request for a team November 2, 2026 18:44
@SalmaSamy SalmaSamy closed this Nov 2, 2026

@ted-xie ted-xie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you closed the PR before I could finish typing, but I had some high level questions here. but this looks great and I'm looking forward to the final version!

Comment thread buildkite/rollback_vm_image.py Resolved
Comment thread buildkite/rollback_image.py Resolved
Comment thread buildkite/rollback_vm_image.py Resolved
@SalmaSamy

Copy link
Copy Markdown
Member Author

@ted-xie Ooops sorry, my agent decided it's ready for review on my behalf :D
Thanks for the notes though, I will look into them.

@SalmaSamy

Copy link
Copy Markdown
Member Author

Updated and tested

@meteorcloudy

Copy link
Copy Markdown
Member

What happens if we identify some issue after promoting them to prod, can we still rollback with this script/process?

Add buildkite/rollback_vm_image.py to deprecate the newest active READY
image in each GCE image family in favor of the previous one and print
the undo and create_instances.py commands.

When validation presubmits fail in trigger_testing_presubmits.py, keep
the error annotation with the infra-vs-test hint, upload
pipelines/vm-image-rollback.yml with ROLLBACK_FAMILIES and
ROLLBACK_GROUPS interpolated for the target org, and exit 0 so the
pipeline pauses at a block step offering rollback or continue.
Expand the rollback plan comprehension into a plain loop and add short
section comments in main() so the flow and fail-early checks are clear.
@SalmaSamy

Copy link
Copy Markdown
Member Author

What happens if we identify some issue after promoting them to prod, can we still rollback with this script/process?

Yes, we can run this script manually. I added a description of how to use it at the top of the file.

@SalmaSamy
SalmaSamy merged commit 146745b into master Nov 5, 2026
11 checks passed
@SalmaSamy
SalmaSamy deleted the image-rollback branch November 5, 2026 12:54
["buildkite-agent", "pipeline", "upload", "../pipelines/vm-image-rollback.yml"],
env={**os.environ, "ROLLBACK_FAMILIES": families, "ROLLBACK_GROUPS": groups},
)
return 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns 0 when the presubmits failed, so the step shows as passed in the build history. I understand this is needed for the "continue" option. Please add a comment here, and make the annotation clearly say that the presubmits FAILED.

)
return 1

# Look up the newest and previous image of every family before changing anything,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This undo is incomplete. Making the image active again does not change the running agents. Please also print ./create_instances.py <groups> here.

decision="$$(buildkite-agent meta-data get vm-image-decision)"
if [ "$$decision" = rollback ]; then
./rollback_vm_image.py "${ROLLBACK_FAMILIES}" && ./create_instances.py "${ROLLBACK_GROUPS}"
exit 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please add a comment that exit 1 stops the pipeline on purpose after a rollback. Also, if create_instances.py fails, the image is already deprecated but the agents still run the new image. Please log this case clearly.


Used by pipelines/vm-image-rollback.yml when image presubmits fail, and can be
run manually, e.g. if a problem shows up after promotion to prod:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this repeats the family-to-group mapping in instances.yml (image_family). Reading it from that file would prevent the two from drifting apart.

@meteorcloudy

Copy link
Copy Markdown
Member

Sorry, my agent identified a few things after I approve..

@SalmaSamy

Copy link
Copy Markdown
Member Author

Sorry, my agent identified a few things after I approve..

No Problem. I will address them in a follow up PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants