Skip to content

fix(cfg): keep parallel downloads off when max-parallel-downloads is 0 - #5268

Open
0z5a wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
0z5a:fix/max-parallel-downloads-zero
Open

0z5a wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
0z5a:fix/max-parallel-downloads-zero

Conversation

@0z5a

@0z5a 0z5a commented Nov 17, 2026

Copy link
Copy Markdown

Description

The config-file docs say for max-parallel-downloads: "0: Disables parallel downloads. Can only be used if --enable-parallel-downloads is not passed or is passed as false."
Since parallel downloads became default-on for file cache users, resolveParallelDownloadsValue sets EnableParallelDownloads = true whenever the file cache is enabled and enable-parallel-downloads is not set by the user, regardless of max-parallel-downloads. Validation runs before rationalization, so the existing "must not be 0 when enable-parallel-downloads is true" check never sees this case.
The result: --cache-dir=... --file-cache-max-size-mb=100 --file-cache-max-parallel-downloads=0 ends with parallel downloads on. NewJobManager only applies the limit when MaxParallelDownloads > 0 and otherwise uses math.MaxInt64, so the global limit on download goroutines is gone.
This change skips the implicit enable when max-parallel-downloads is 0. An explicit enable-parallel-downloads: true together with 0 is still rejected by validation as before, and the default (no flags) and -1 (unlimited) still enable parallel downloads.

Link to the issue in case of a bug fix.

Fixes #5267

Testing details

  1. Manual - Ran the flag -> ValidateConfig -> Rationalize pipeline with --cache-dir=/tmp/x --file-cache-max-size-mb=100 --file-cache-max-parallel-downloads=0: before the change enable-parallel-downloads=true, after it false. Same for the equivalent YAML config (cache-dir + file-cache: {max-size-mb: 100, max-parallel-downloads: 0}). The default, enable-parallel-downloads=false and enable-parallel-downloads=true cases are unchanged.
  2. Unit tests - Added two cases to TestRationalize_ParallelDownloadsConfig (max-parallel-downloads 0 -> disabled, -1 -> enabled) and set an explicit max-parallel-downloads on the existing file-cache-enabled case. The new 0 case fails on master and passes with the change. go test ./cfg/... passes.
  3. Integration tests - NA

Any backward incompatible change? If so, please explain.

Only for configs that set max-parallel-downloads: 0 without setting enable-parallel-downloads: they now get parallel downloads disabled (as documented) instead of enabled with no global limit.

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

The docs say max-parallel-downloads 0 disables parallel downloads. With
the file cache enabled and enable-parallel-downloads unset,
resolveParallelDownloadsValue turned parallel downloads on anyway, after
validation had already run, and NewJobManager then used no global limit.

Skip the implicit enable when max-parallel-downloads is 0.

Fixes GoogleCloudPlatform#5267
@0z5a
0z5a requested a review from a team as a code owner November 17, 2026 16:32
@0z5a
0z5a requested a review from meet2mky November 17, 2026 16:32

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the configuration rationalization logic to ensure that parallel downloads are not automatically enabled when max-parallel-downloads is explicitly set to 0, which signifies that parallel downloads are disabled. It also adds corresponding unit tests to verify this behavior for different configuration values (0, -1, and positive integers). I have no feedback to provide as there are no review comments.

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.

file-cache max-parallel-downloads: 0 turns on parallel downloads with no global limit instead of disabling them

1 participant

⌂ 换网址