Skip to content

[mergebot] Do not refuse docker-affecting merges on tree skew, just warn - #192522

Closed
atalman wants to merge 1 commit into
pytorch:mainfrom
atalman:atalman/allow-docker-skew-merge
Closed

atalman wants to merge 1 commit into
pytorch:mainfrom
atalman:atalman/allow-docker-skew-merge

Conversation

@atalman

@atalman atalman commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #191508.

What #191508 added, and what changes here

It added two gates for docker-affecting PRs, both in merge_into so force merges
cannot bypass them:

  1. check_docker_builds_ready — the PR's own ciflow/docker builds must have
    run and passed. Unchanged by this PR. Pending builds still raise
    MandatoryChecksMissingError so a normal merge waits; missing/failed builds are
    still refused.
  2. check_no_docker_merge_skew — additionally required the .ci/docker tree of
    the merge commit to equal the tree ciflow/docker built on the PR head, and
    refused the merge otherwise. This PR downgrades it to a warning.

So the "all the builds are green" requirement is fully retained; what goes away is
the extra requirement that the base branch not have moved.

Why

Requiring the two trees to match means a docker PR has to win a race against the
base branch, and a rebase only helps until the next docker-affecting PR lands. On
a busy day a PR can bounce indefinitely. #190639 hit it twice in a row — the
PR-head tree moved (08b9699a → 75ce86e4) after a rebase while the merge-commit
tree stayed ab961773:

Refusing to merge: this PR modifies the CI docker images, but the .ci/docker tree
of the merge commit (ab961773...) does not match the tree that ciflow/docker built
and tested on the PR head (75ce86e4...)

A missing post-merge image is not fatal, which is the key point:

  • docker-builds.yml triggers on push to main / release/*, so the merged
    tree's images get built and pushed right after the merge lands.
  • test-infra's calculate-docker-image polls for the image before giving up —
    docker manifest inspect in a loop, sleep 300 per iteration, up to 120
    minutes for non-docker-build jobs — and then falls through to rebuild=true
    and builds it locally.

So a skew costs time on the first trunk jobs after the merge (waiting for
docker-builds, or a local rebuild with longer TTS), not a hard failure. Trading
that against docker PRs being unable to land seems like the better default.

Kept: the diagnostic

The mismatch is still printed to the merge job log, so a slow or rebuilding trunk
job can be correlated with the land race that caused it:

WARNING: docker land race on PR #NNNNN: the .ci/docker tree of the merge commit
(...) does not match the tree that ciflow/docker built and tested on the PR head
(...). ... the first trunk jobs after this merge may wait for docker-builds to
publish the merged tree's images, or rebuild them locally. Merging anyway.

Renamed check_no_docker_merge_skew → warn_on_docker_merge_skew so the name
matches the behaviour.

Test plan

  • python -m pytest .github/scripts/test_trymerge.py → 74 passed, 2 skipped
    (the 4 docker-gate tests included; none referenced the renamed function).
  • py_compile clean; no remaining references to the old name
    (grep -rn check_no_docker_merge_skew .github/ → empty).
  • MergeRuleFailedError is still used in 7 other places, so the import is not
    orphaned.

Trade-off, stated plainly

This intentionally reopens the window that #191508 closed: a docker PR can now
land whose post-merge images were never built or tested, which is the shape of the
#190927 / #186302 land race cited in that PR. The mitigation is that the images
are auto-published by docker-builds.yml on the merge and that jobs wait for
them, so the failure mode is latency rather than red trunk. If dev-infra would
rather keep a hard gate, an alternative is to keep refusing only when
check_docker_builds_ready did not pass, i.e. exactly the unbuilt-image case,
and always allow the pure-skew case — happy to switch to that.

@atalman
atalman requested a review from a team as a code owner August 7, 2026 17:06
@pytorch-bot

pytorch-bot Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192522

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit b11e21b with merge base 411e87a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Aug 7, 2026
Follow-up to pytorch#191508. That PR added two gates for docker-affecting PRs. The
first, check_docker_builds_ready, requires the PR's own ciflow/docker builds to
have run and passed -- that one stays. The second, check_no_docker_merge_skew,
additionally required the .ci/docker tree of the *merge commit* to equal the
tree ciflow/docker built on the PR head, and refused the merge otherwise:

    Refusing to merge: this PR modifies the CI docker images, but the .ci/docker
    tree of the merge commit (...) does not match the tree that ciflow/docker
    built and tested on the PR head (...)

In practice that makes a docker PR win a race against the base branch. Rebasing
only helps until the next docker-affecting PR lands, so on a busy day a PR can
bounce indefinitely -- pytorch#190639 hit it twice in a row, with the PR-head tree
moving (08b9699 -> 75ce86e) while the merge-commit tree stayed the same.

Downgrade it to a warning:

- The builds-are-green requirement is unchanged: check_docker_builds_ready still
  blocks (and MandatoryChecksMissingError still makes a normal merge wait).
- A missing post-merge image is not fatal. docker-builds.yml runs on push to the
  default branch, so it publishes the merged tree's images right after the merge,
  and test-infra's calculate-docker-image polls for the image (docker manifest
  inspect, up to 120 min) before falling through to rebuilding it locally. So a
  skew costs time on the first trunk jobs rather than breaking them.
- The mismatch is still printed to the merge job log, so a slow or rebuilding
  trunk job can be correlated with the land race that caused it.

Renamed to warn_on_docker_merge_skew so the name matches the behaviour.
@atalman
atalman force-pushed the atalman/allow-docker-skew-merge branch from 236e4a5 to b11e21b Compare August 7, 2026 17:09

@ezyang ezyang 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.

I'm approving not because I think this is the right thing to do but because it will unblock Docker work. IMO we need a merge queue for Docker image changes in this case

@ezyang ezyang 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.

approving to unbreak docker lands, but a warn only with high volume means the gate isn't fixing the real problem

@ezyang ezyang 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.

.

@atalman

atalman commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "lint looks good, lets merge"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

ankitbhrdwj pushed a commit to ankitbhrdwj/pytorch that referenced this pull request Aug 12, 2026
…arn (pytorch#192522)

Follow-up to pytorch#191508.

## What pytorch#191508 added, and what changes here

It added two gates for docker-affecting PRs, both in `merge_into` so force merges
cannot bypass them:

1. **`check_docker_builds_ready`** — the PR's own `ciflow/docker` builds must have
   run and passed. **Unchanged by this PR.** Pending builds still raise
   `MandatoryChecksMissingError` so a normal merge waits; missing/failed builds are
   still refused.
2. **`check_no_docker_merge_skew`** — additionally required the `.ci/docker` tree of
   the *merge commit* to equal the tree `ciflow/docker` built on the PR head, and
   refused the merge otherwise. **This PR downgrades it to a warning.**

So the "all the builds are green" requirement is fully retained; what goes away is
the extra requirement that the base branch not have moved.

## Why

Requiring the two trees to match means a docker PR has to win a race against the
base branch, and a rebase only helps until the next docker-affecting PR lands. On
a busy day a PR can bounce indefinitely. pytorch#190639 hit it twice in a row — the
PR-head tree moved (`08b9699a` → `75ce86e4`) after a rebase while the merge-commit
tree stayed `ab961773`:

```
Refusing to merge: this PR modifies the CI docker images, but the .ci/docker tree
of the merge commit (ab96177...) does not match the tree that ciflow/docker built
and tested on the PR head (75ce86e...)
```

**A missing post-merge image is not fatal**, which is the key point:

- `docker-builds.yml` triggers on `push` to `main` / `release/*`, so the merged
  tree's images get built and pushed right after the merge lands.
- test-infra's `calculate-docker-image` polls for the image before giving up —
  `docker manifest inspect` in a loop, `sleep 300` per iteration, up to 120
  minutes for non-docker-build jobs — and then falls through to `rebuild=true`
  and builds it locally.

So a skew costs **time** on the first trunk jobs after the merge (waiting for
docker-builds, or a local rebuild with longer TTS), not a hard failure. Trading
that against docker PRs being unable to land seems like the better default.

## Kept: the diagnostic

The mismatch is still printed to the merge job log, so a slow or rebuilding trunk
job can be correlated with the land race that caused it:

```
WARNING: docker land race on PR #NNNNN: the .ci/docker tree of the merge commit
(...) does not match the tree that ciflow/docker built and tested on the PR head
(...). ... the first trunk jobs after this merge may wait for docker-builds to
publish the merged tree's images, or rebuild them locally. Merging anyway.
```

Renamed `check_no_docker_merge_skew` → `warn_on_docker_merge_skew` so the name
matches the behaviour.

## Test plan

- `python -m pytest .github/scripts/test_trymerge.py` → **74 passed, 2 skipped**
  (the 4 docker-gate tests included; none referenced the renamed function).
- `py_compile` clean; no remaining references to the old name
  (`grep -rn check_no_docker_merge_skew .github/` → empty).
- `MergeRuleFailedError` is still used in 7 other places, so the import is not
  orphaned.

## Trade-off, stated plainly

This intentionally reopens the window that pytorch#191508 closed: a docker PR can now
land whose post-merge images were never built or tested, which is the shape of the
pytorch#190927 / pytorch#186302 land race cited in that PR. The mitigation is that the images
are auto-published by `docker-builds.yml` on the merge and that jobs wait for
them, so the failure mode is latency rather than red trunk. If dev-infra would
rather keep a hard gate, an alternative is to keep refusing only when
`check_docker_builds_ready` did **not** pass, i.e. exactly the unbuilt-image case,
and always allow the pure-skew case — happy to switch to that.

Pull Request resolved: pytorch#192522
Approved by: https://github.com/tinglvv, https://github.com/izaitsevfb, https://github.com/ezyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants