Skip to content

Stop generating constraints for PRs that do not use them - #76685

Merged
potiuk merged 1 commit into
mainfrom
ci/generate-constraints-only-when-needed
Nov 10, 2026
Merged

potiuk merged 1 commit into
mainfrom
ci/generate-constraints-only-when-needed

Conversation

@shahar1

@shahar1 shahar1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

This PR replaces #76656. It has the same commit, rebased onto main and moved to an apache/airflow branch. A stacked PR needs all its branches in the same repository.

Why

The Generate constraints job runs on every PR that builds the CI image. Many of these PRs do not use its output.

The data comes from Tests (AMD) PR runs from 2026-10-16 to 2026-11-05. There were 5177 runs. I sampled 15 runs per day, 308 runs in total.

Measurement Value
Runs that execute the job 60%
Jobs per day About 149
Runner time per day About 24 hours
Part of all job-minutes 2.0%
Jobs on ubuntu-22.04 91%
Runs that execute the job but do not build the PROD image 46%
pypi.org JSON requests per job 108
pypi.org JSON requests per day About 16,000
Packages resolved per job 725

In the 46% of runs without a PROD image, no job reads the output.

The job also causes failures that are not related to the PR. I read the logs of all 51 jobs that failed in this period:

Cause Jobs
Network errors (pypi.org 36, nodejs.org 3, api.github.com 1) 40
Provider downgrade check on backports, caused by release candidate pins 7
PyPI did not serve a pinned version (common-compat==1.22.0) 1
Errors caused by the PR 3

38 of the 51 failures are on PRs that do not change dependency files.

Two of the 3 PR errors are on PRs that change dependency files (#74696, #76317). These PRs still run the job after this change. The third PR (#76548) also failed React UI tests and Static checks.

How

This PR adds two selective-check outputs:

Output Value is true when
generate-pypi-constraints The CI image is built and one of these conditions is true: a pyproject.toml file changed, uv.lock changed, full tests are necessary, the run is a canary, or the PR has the upgrade to newer dependencies label
generate-constraints generate-pypi-constraints is true, or the PROD image is built

Full tests are necessary when the job's workflow or script changes. Thus, a change to these files still runs the PyPI step.

ci-amd.yml and ci-arm.yml use these outputs to control the job.

The PROD image build reads only the constraints-source-providers file. When generate-pypi-constraints is false and the PROD image is built, the job makes only that file. It does not build the provider, Airflow and Task SDK wheels, and it does not run the PyPI step.

The other workflows that call generate-constraints.yml set their own inputs. This PR does not change them.

Expected result

The job does not run on PRs that do not build the PROD image and do not change dependencies. These runs used 43% of the job's minutes in the sample. The steps removed from the other runs used 29%.

The maximum saving is 72% of the job's minutes, about 17 runner hours per day. The real saving is smaller because PRs that change dependencies still run the job. I did not measure the number of these PRs.

Risk

A PR can break the PyPI resolution or the wheel builds without a change to dependency files. This job does not find that error on the PR after this change. The canary runs find it instead. AMD and ARM canaries each run two times per day.

This type of failure did not occur in the 21 days of data.

Verification

Check Result
test_selective_checks.py and test_verification_plan.py 443 passed, including the new test_generate_constraints cases
prek, pre-commit stage Passed, except lychee-docker
prek, manual stage Passed
All tests in dev/breeze/tests 2491 passed, 1 failed, 16 errors

lychee-docker did not start because the local Docker proxy refused a writable bind mount. I ran lycheeverse/lychee:nightly on the two changed documents with a read-only mount. The result is 0 errors.

The 16 errors are botocore.exceptions.MissingDependencyException in test_release_management_commands.py. The cause is that publish_docs_to_s3.py creates AWS clients during import. #76658 fixes this.

The failed test is test_reproducible_build_matches_svn. It does not use AWS. It failed because the local Docker proxy refused buildx_buildkit_default, so docker build did not start. This test compares a real build with real SVN artifacts, so it cannot use mocks. CI skips it.

The workflow changes have not run in CI. The CI run of this PR must confirm them.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

🤖 Generated with Claude Code

https://claude.ai/code/session_01BVx6g6v9hW7wi1tV4bqvrp

Generate constraints ran for every PR that builds the CI image, about 149
jobs a day, though for 46% of those runs nothing reads its output. The PROD
image, its only reader on an ordinary PR, reads just the source-providers
file. The PyPI step asks PyPI for 108 providers and resolves 725 packages
against what it serves, which a change that touches no dependency cannot
affect.

That step turned PyPI outages into red PRs: of the 51 jobs that failed from
2026-10-16 to 2026-11-05, 40 were network errors and 38 were on PRs that
touched no dependency files. The only two failures no other job caught were
in PRs that changed dependency files, which still run it. Canary runs still
cover the state of PyPI.

Claude-Session: https://claude.ai/code/session_01BVx6g6v9hW7wi1tV4bqvrp
@shahar1
shahar1 added this pull request to stack #76687 November 7, 2026 15:11
@shahar1 shahar1 changed the title ci/generate constraints only when needed Stop generating constraints for PRs that do not use them Nov 7, 2026
@shahar1
shahar1 marked this pull request as ready for review November 7, 2026 15:12
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

The re-run of the jobs stopped by EC2 Spot interruptions finished: attempt 2 passed.

@potiuk potiuk left a comment

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.

Gating Generate constraints on the PROD image build and dependency changes is consistent with every consumer of its output: the PROD image build and its tests need it only when it runs, Update constraints runs only when the PyPI step does, and main canaries and dispatched release-branch runs keep the full resolution.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

@potiuk
potiuk merged commit e1150d7 into main Nov 10, 2026
333 of 349 checks passed
@potiuk
potiuk deleted the ci/generate-constraints-only-when-needed branch November 10, 2026 17:13
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-4-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
❌ v3-4-test Commit Link

You can attempt to backport this manually by running:

cherry_picker e1150d7 v3-4-test

This should apply the commit to the v3-4-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

potiuk added a commit that referenced this pull request Nov 10, 2026
…76685) (#76849)

Generate constraints ran for every PR that builds the CI image, about 149
jobs a day, though for 46% of those runs nothing reads its output. The PROD
image, its only reader on an ordinary PR, reads just the source-providers
file. The PyPI step asks PyPI for 108 providers and resolves 725 packages
against what it serves, which a change that touches no dependency cannot
affect.

That step turned PyPI outages into red PRs: of the 51 jobs that failed from
2026-10-16 to 2026-11-05, 40 were network errors and 38 were on PRs that
touched no dependency files. The only two failures no other job caught were
in PRs that changed dependency files, which still run it. Canary runs still
cover the state of PyPI.

Claude-Session: https://claude.ai/code/session_01BVx6g6v9hW7wi1tV4bqvrp
(cherry picked from commit e1150d7)
Generated-by: Claude Opus 5

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
vatsrahul1001 pushed a commit that referenced this pull request Nov 27, 2026
…76685) (#76849)

Generate constraints ran for every PR that builds the CI image, about 149
jobs a day, though for 46% of those runs nothing reads its output. The PROD
image, its only reader on an ordinary PR, reads just the source-providers
file. The PyPI step asks PyPI for 108 providers and resolves 725 packages
against what it serves, which a change that touches no dependency cannot
affect.

That step turned PyPI outages into red PRs: of the 51 jobs that failed from
2026-10-16 to 2026-11-05, 40 were network errors and 38 were on PRs that
touched no dependency files. The only two failures no other job caught were
in PRs that changed dependency files, which still run it. Canary runs still
cover the state of PyPI.

Claude-Session: https://claude.ai/code/session_01BVx6g6v9hW7wi1tV4bqvrp
(cherry picked from commit e1150d7)
Generated-by: Claude Opus 5

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants