Skip to content

fix(ops): scale the deploy-pipelines chunk deadline with the chunk size - #31976

Merged
Khairajani merged 3 commits into
mainfrom
fix/deploy-pipelines-timeout-reporting
Aug 26, 2026
Merged

Khairajani merged 3 commits into
mainfrom
fix/deploy-pipelines-timeout-reporting

Conversation

@Khairajani

@Khairajani Khairajani commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Fixes #32004.

deploy-pipelines POSTs chunks of pipeline IDs to POST /v1/services/ingestionPipelines/bulk/deploy. That endpoint deploys them sequentially — pipelineIdList.stream().map(...), no parallelism — but the client bounded the request with a hardcoded 2 minute deadline:

int chunkSize = 20;
...
.timeout(Duration.ofMinutes(2))

That budgets 6 seconds per pipeline. A freshly restarted pipeline service does not write and parse a DAG that fast, so the client abandons a request whose work is still progressing.

A client deadline does not cancel the server. The abandoned chunk keeps deploying while the command marks all 20 pipelines FAILED and exits 1 — and a Kubernetes restartPolicy: OnFailure then replays the whole run on top of work still in flight, adding load to an operation that was already succeeding.

Observed on a 92-pipeline instance during a version upgrade: the command reported failure while 90 of 92 pipelines were deployed. The two exceptions had been undeployed for months and were unrelated.

Deploying 91 pipelines via bulk API calls in chunks of 20
Processing chunk 1 of 5 (pipelines 1-20)
Failed to deploy pipeline chunk
java.net.http.HttpTimeoutException: request timed out
    at org.openmetadata.service.util.OpenMetadataOperations.deployPipelineChunk(OpenMetadataOperations.java:3040)

The deadline also degrades silently as a catalog grows — the same instance was 63 pipelines a few months earlier.

Relation to #28500

#28500 is often assumed to cover this. It does not, and it is already fixed.

That issue was a genuine concurrency bug in the Python DAG builder: Airflow 3's process-global DagContext autoregister raising KeyError: 'unusual_prefix_<hash>_<other dag>' when DAG files parse concurrently. The fix replaced with DAG(...) as dag: with an explicit dag= reference, and build_dag on both main and 2.0.0-release already carries it.

This is a different layer and a different symptom — a client-side deadline in the Java ops CLI (HttpTimeoutException in deployPipelineChunk), not a DAG-parse crash in the pipeline service. And the bulk deploy path has no parallelism to race in the first place (.stream(), synchronous client.send(), sequential chunk loop), so this timeout is not a concurrency problem at all. Fixing #28500 could not have changed it, and this change does not affect #28500.

Change

  • Budget the deadline per pipeline and multiply by the chunk size, floored at the previous 2 minutes so nothing gets a shorter deadline than before. Defaults give 600s for a chunk of 20 instead of 120s.
  • Expose --chunk-size and --seconds-per-pipeline. The command previously declared no options at all, so neither value was reachable from a deployment configuration (the Helm chart's deployPipelinesConfig.additionalArgs had nothing to pass).
  • Extract the deadline calculation and the failure check as static functions so both are unit testable without a database, following the existing planSmartReindex pattern.
  • DeployRequest record keeps the chunk method within the parameter limit.

This is a client-side change only. The bulk/deploy endpoint is untouched. No behaviour change to the success path, and genuine failures still exit non-zero.

Not addressed here

Reporting. An abandoned chunk is still recorded as failed. The persisted deployed flag cannot correct it: the deploy path only ever calls setDeployed(true) and never resets it, so it records whether a pipeline was ever deployed rather than what this run did. Reading it to clear a timeout would turn a genuine failure into a silent success on any redeploy — which post-upgrade deploy-pipelines always is. A per-run answer needs the deploy response itself; subdividing a timed-out chunk and re-POSTing is the plausible approach, but it re-sends work that may still be in flight, so it wants its own design pass.

Overlap. deployPipelineChunk swallows the timeout, so the loop POSTs the next chunk while the previous one is still executing server side. Longer deadlines make this rarer but do not remove it.

Cancellation. Fixing it properly means an async endpoint (202 + job handle + poll) so a client give-up cannot orphan server work.

Measured

Per-pipeline deploy latency on a healthy, idle 92-pipeline instance, three sequential single-pipeline chunks through bulk/deploy:

elapsed
deploy 1 6.92s
deploy 2 8.68s
deploy 3 13.54s

The previous deadline budgeted 120s / 20 = 6.0s per pipeline. Every measurement exceeded that, including the fastest: 20 x 6.92 = 138s > 120s. A full chunk could not have completed inside the old deadline even at best-case latency on an idle server, so this was not only a cold-start problem. Latency also climbs across consecutive deploys as the pipeline service takes on load.

Against the slowest observed 13.54s, a chunk of 20 needs ~270s. The new default budgets 600s, leaving headroom for the cold pipeline service that a post-upgrade run actually faces.

A chunk of 5 driven from outside the cluster returned 504 at ~65s, but that is the load balancer's 60s idle timeout rather than a server limit, and does not apply to this command: metadataApiEndpoint resolves to the in-cluster service, so the deploy request never traverses the ingress.

Testing

OpenMetadataOperationsDeployPipelinesTest — 10 unit tests: deadline scaling, the floor, that the default deadline exceeds the previous fixed 2 minutes, option validation, failure detection, and picocli binding for both options including their declared defaults. Passes alongside the existing OpenMetadataOperationsSmartReindexTest. mvn spotless:apply clean.

Also exercised end to end by invoking the command from this branch against a running server and MySQL:

invocation result
(no options) chunks of 20 with a 600s deadline per chunk, all pipelines deployed, exit 0
--chunk-size 3 --seconds-per-pipeline 45 chunks of 3 with a 135s deadline per chunk, 2 chunks, every response code=200, exit 0
--chunk-size 1 --seconds-per-pipeline 5 floors to 120s, 5 chunks, exit 0
--chunk-size 0 --chunk-size must be at least 1, got 0, exit 1, returns immediately instead of exhausting the heap
--chunk-size -5 --seconds-per-pipeline 0 both values reported, exit 1
deploy-pipelines --help both options render with their descriptions

Behaviour is identical on main, 2.0.0-release, origin/1.13 and 1.13.4-release, so this applies to both release lines and can be picked to 1.13.

deploy-pipelines POSTs chunks of pipeline IDs to the bulk deploy endpoint,
which registers each pipeline sequentially, but bounded the request with a
fixed 2 minute deadline. At the default chunk size of 20 that budgets 6
seconds per pipeline, which a freshly restarted pipeline service does not
meet, so the client abandoned requests whose work was still progressing.

A client deadline does not cancel the server, so the abandoned chunk kept
deploying while the command marked all 20 pipelines FAILED and exited 1. A
Kubernetes restartPolicy of OnFailure then replayed the whole run on top of
work still in flight, adding load to an operation that was already
succeeding. On a catalog of 92 pipelines this reported failure while 90 were
deployed.

Budget the deadline per pipeline and multiply by the chunk size, so it no
longer silently becomes too short as a catalog grows, and expose the chunk
size and the per-pipeline budget as options. The command previously accepted
none, so neither value was reachable from a deployment configuration.

Extract the deadline calculation and the failure check as static functions so
the scaling and the exit code are unit testable without a database.

Reporting is left unchanged: an abandoned chunk is still recorded as failed.
The persisted deployed flag cannot correct it, because the deploy path only
ever sets it to true and never resets it, so it records whether a pipeline was
ever deployed rather than what this run did. Reading it to clear a timeout
would turn a genuine failure into a silent success on any redeploy. A per-run
answer needs the deploy response itself, which is a separate change.
@Khairajani
Khairajani requested a review from a team as a code owner August 24, 2026 15:30
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Khairajani Khairajani added safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Aug 24, 2026
Exposing --chunk-size made a value that was previously hardcoded to 20
reachable from outside, and chunkList advances its loop with i += chunkSize.
A chunk size of 0 never advances, appending empty chunks until the heap is
exhausted, and a negative size makes subList throw, which the surrounding
handler turns into every pipeline being reported as FAILED.

Validate both options before the deploy runs and report each offending value,
rather than clamping, so a mistyped flag is not silently replaced by a
different deadline. Guard chunkList as well, so a non-positive size fails
loudly instead of spinning if another caller ever skips validation.

A non-positive --seconds-per-pipeline was already safe, since the deadline
floors at the previous fixed 2 minutes, but it is rejected too rather than
silently falling back to the deadline this option exists to move away from.

Drops the deployChunkTimeout(0, 30) assertion, which implied a chunk size of
0 was supported when it now fails validation.
Parsing the command with picocli asserts the new options bind to the values
passed on the command line and that the declared defaults still match the
20 and 30 the description documents. Neither was covered: the existing tests
call the helpers directly, so a mistyped option name or a default drifting
from its description would not have failed anything.

Reads the defaults from the command spec rather than the parse result, since
matchedOptionValue only reports options actually present on the command line.

Needs no database, so it stays a unit test.
@gitar-bot

gitar-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Scales the deploy-pipelines chunk timeout dynamically based on chunk size and adds lower-bound validation for deployment options, addressing the non-positive chunk size issue. No issues found.

✅ 1 resolved
✅ Edge Case: --chunk-size=0 causes an infinite loop / hang

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java:3395-3409 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java:3012 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/OpenMetadataOperations.java:3123-3130
The new --chunk-size option is passed straight into chunkList, whose loop advances with i += chunkSize. A value of 0 never advances i, producing an infinite loop that hangs the command (and, under restartPolicy: OnFailure, gets replayed forever). Negative values also misbehave (subList throws and every pipeline is falsely marked FAILED). Since the value now comes from external config, validate it before use — e.g. clamp/reject chunkSize < 1 at the start of deployPipelines and log a clear error.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 12840e3b324b003523ac1685364b2f916150f9e6 in Playwright run 32747456670, attempt 1.

✅ 553 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 1h 7m 55s

⏱️ Max setup 6m 21s · max shard execution 17m 18s · max shard-job elapsed before upload 26m 55s · reporting 4s

🌐 215.66 requests/attempt · 2.83 app boots/UI scenario · 24.28% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 24.28% (convergence target: at most 15%).
  • Browser traffic was 215.66 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.83 per UI scenario (1622 boots / 574 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 133 0 0 0 0 0
✅ Shard chromium-02 140 0 0 0 0 0
✅ Shard chromium-03 126 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Khairajani
Khairajani added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit 84ee0c2 Aug 26, 2026
116 of 117 checks passed
@Khairajani
Khairajani deleted the fix/deploy-pipelines-timeout-reporting branch August 26, 2026 10:13
Khairajani added a commit that referenced this pull request Sep 1, 2026
…#32005) + scale the deploy-pipelines deadline (#31976) (#32101)

* fix(airflow-apis): stop re-parsing the whole DAG folder on every pipeline deploy (#32005)

* fix(airflow-apis): stop re-parsing the whole DAG folder on every deploy

`get_dagbag` built a DagBag over the entire DAG folder and called `collect_dags`,
so each deploy parsed every DAG in the deployment. That makes a single deploy cost
O(total DAGs) and a bulk deploy O(total DAGs^2).

On Airflow 2.x the folder was never actually walked: `read_dags_from_db=True` made
both `collect_dags` and `collect_dags_from_db` early return, and DAGs came from the
serialized-DAG table. The Airflow 3.x support gate dropped that kwarg, which turned
an O(1) DB read into an O(N) filesystem walk.

The deploy path does not need a populated bag. `refresh_session_dag` calls
`process_file` on the DAG file it has just written and then asks for that single
`dag_id`, and `process_file` bags the DAG itself. Build the bag with
`collect_dags=False` instead. The kwarg exists on DagBag in both Airflow 2.x and
3.x, so the version branching goes away with it.

The folder walk was also masking `process_file`: `collect_dags` stamps
`file_last_changed` for every file it walks, including the one just written, so the
following `process_file` hit its `only_if_updated` early return and returned no
dags. The DAG was bagged by the folder walk as a side effect rather than by the call
that intends to bag it. The pre-fix test run confirms this - `found_dags` did not
contain the deployed dag.

Drop the `dagbag size` log line, which would now always report 0. The adjacent
`processed dags` line carries the same signal and starts reporting the real dag.

The per-deploy `DagFileProcessorManager` fork in `scan_dags_job_background` is left
alone deliberately. On Airflow 3 `DAG.sync_to_db` delegates to `bulk_write_to_db`,
which writes DagModel and asset rows but does not call `SerializedDagModel.write_dag`,
so that scan is what serializes a newly deployed DAG. Removing or skipping it would
leave deployed pipelines unrunnable.

Tests: `tests/unit/ingestion_pipeline/test_get_dagbag.py` - the bag comes back empty
over a populated folder, `collect_dags` is never called, and `process_file` still
bags the deployed DAG and only that DAG. All three fail before this change.

* fix(airflow-apis): keep the pre-3.0 DagBag path unchanged

`collect_dags` was only added to `DagBag.__init__` in Airflow 2.5 (absent in 2.4.0,
present in 2.5.3), and the plugin declares `apache-airflow>=2.2.2`, so passing it
unconditionally raised `TypeError` on 2.2 through 2.4 and failed every deploy there.

Scope the change to Airflow >= 3.0, which is where the regression is. Below 3.0 the
bag is still built with `read_dags_from_db=True`, which early returns out of
`collect_dags`, so that path never walked the DAG folder and needs no change.

Gate the new tests on Airflow 3 for the same reason.

* fix(airflow-apis): unblock airflow-apis-tests on Airflow 3.3

`TestAirflowOps.setUpClass` passed `include_examples=False` to `DagBag`. Airflow 3.3
dropped that keyword -- DAG discovery is bundle based there, so example DAGs are no
longer a constructor flag -- and Python raises `TypeError` for an unknown keyword.
The call is in class setup, so all three tests in the class error before running.

This is unrelated to the DagBag change in this branch: the test builds its own DagBag
and never calls `get_dagbag`. It broke when the Airflow pin moved from 3.2.2 to 3.3.0
in #31338, and has failed on every branch that reached this job since. Fixed here only
because the job has to be green for this branch to be validated; happy to split it out.

Detect the keyword instead of assuming it, matching the `sync_to_db` and `bag_dag`
compatibility checks already in this setup, so the test keeps working on Airflow 2.x
and on 3.x.

Not changed: the workflow's `paths` filter still only watches
`openmetadata-airflow-apis/**`, so a pin bump in `ingestion/setup.py` cannot trigger
the suite it affects -- which is why this went unnoticed. Widening it would run a
24 minute docker-stack job on a file that changed 26 times in the last 90 days
against this module's 5, so that tradeoff is left to maintainers.

* fix(ops): scale the deploy-pipelines chunk deadline with the chunk size (#31976)

* fix(ops): scale the deploy-pipelines chunk deadline with the chunk size

deploy-pipelines POSTs chunks of pipeline IDs to the bulk deploy endpoint,
which registers each pipeline sequentially, but bounded the request with a
fixed 2 minute deadline. At the default chunk size of 20 that budgets 6
seconds per pipeline, which a freshly restarted pipeline service does not
meet, so the client abandoned requests whose work was still progressing.

A client deadline does not cancel the server, so the abandoned chunk kept
deploying while the command marked all 20 pipelines FAILED and exited 1. A
Kubernetes restartPolicy of OnFailure then replayed the whole run on top of
work still in flight, adding load to an operation that was already
succeeding. On a catalog of 92 pipelines this reported failure while 90 were
deployed.

Budget the deadline per pipeline and multiply by the chunk size, so it no
longer silently becomes too short as a catalog grows, and expose the chunk
size and the per-pipeline budget as options. The command previously accepted
none, so neither value was reachable from a deployment configuration.

Extract the deadline calculation and the failure check as static functions so
the scaling and the exit code are unit testable without a database.

Reporting is left unchanged: an abandoned chunk is still recorded as failed.
The persisted deployed flag cannot correct it, because the deploy path only
ever sets it to true and never resets it, so it records whether a pipeline was
ever deployed rather than what this run did. Reading it to clear a timeout
would turn a genuine failure into a silent success on any redeploy. A per-run
answer needs the deploy response itself, which is a separate change.

* fix(ops): reject a non-positive deploy-pipelines chunk size

Exposing --chunk-size made a value that was previously hardcoded to 20
reachable from outside, and chunkList advances its loop with i += chunkSize.
A chunk size of 0 never advances, appending empty chunks until the heap is
exhausted, and a negative size makes subList throw, which the surrounding
handler turns into every pipeline being reported as FAILED.

Validate both options before the deploy runs and report each offending value,
rather than clamping, so a mistyped flag is not silently replaced by a
different deadline. Guard chunkList as well, so a non-positive size fails
loudly instead of spinning if another caller ever skips validation.

A non-positive --seconds-per-pipeline was already safe, since the deadline
floors at the previous fixed 2 minutes, but it is rejected too rather than
silently falling back to the deadline this option exists to move away from.

Drops the deployChunkTimeout(0, 30) assertion, which implied a chunk size of
0 was supported when it now fails validation.

* test(ops): cover picocli binding for the deploy-pipelines options

Parsing the command with picocli asserts the new options bind to the values
passed on the command line and that the declared defaults still match the
20 and 30 the description documents. Neither was covered: the existing tests
call the helpers directly, so a mistyped option name or a default drifting
from its description would not have failed anything.

Reads the defaults from the command spec rather than the parse result, since
matchedOptionValue only reports options actually present on the command line.

Needs no database, so it stays a unit test.

* style: drop unused static imports flagged by spotless on 2.0

`TestCaseResolutionStatusResource` imports `CommonUtil.listOrEmpty` and
`CommonUtil.nullOrEmpty` but no longer uses either, so `mvn spotless:check` fails and
the `java-checkstyle` job is red for every PR targeting this branch -- #32095 and
#32093 fail identically. The usages went away in #32017 while the imports stayed.

Import-only change, produced by `mvn spotless:apply`; no logic touched. Needed here
only so this backport can be validated.

`main` needs no equivalent fix: both symbols are imported and used five times each in
that file there. On `1.13` the imports do not exist. This is 2.0-only.
pmbrull pushed a commit that referenced this pull request Sep 2, 2026
#32005) + scale the deploy-pipelines deadline (#31976) (#32100)

* fix(airflow-apis): stop re-parsing the whole DAG folder on every pipeline deploy (#32005)

* fix(airflow-apis): stop re-parsing the whole DAG folder on every deploy

`get_dagbag` built a DagBag over the entire DAG folder and called `collect_dags`,
so each deploy parsed every DAG in the deployment. That makes a single deploy cost
O(total DAGs) and a bulk deploy O(total DAGs^2).

On Airflow 2.x the folder was never actually walked: `read_dags_from_db=True` made
both `collect_dags` and `collect_dags_from_db` early return, and DAGs came from the
serialized-DAG table. The Airflow 3.x support gate dropped that kwarg, which turned
an O(1) DB read into an O(N) filesystem walk.

The deploy path does not need a populated bag. `refresh_session_dag` calls
`process_file` on the DAG file it has just written and then asks for that single
`dag_id`, and `process_file` bags the DAG itself. Build the bag with
`collect_dags=False` instead. The kwarg exists on DagBag in both Airflow 2.x and
3.x, so the version branching goes away with it.

The folder walk was also masking `process_file`: `collect_dags` stamps
`file_last_changed` for every file it walks, including the one just written, so the
following `process_file` hit its `only_if_updated` early return and returned no
dags. The DAG was bagged by the folder walk as a side effect rather than by the call
that intends to bag it. The pre-fix test run confirms this - `found_dags` did not
contain the deployed dag.

Drop the `dagbag size` log line, which would now always report 0. The adjacent
`processed dags` line carries the same signal and starts reporting the real dag.

The per-deploy `DagFileProcessorManager` fork in `scan_dags_job_background` is left
alone deliberately. On Airflow 3 `DAG.sync_to_db` delegates to `bulk_write_to_db`,
which writes DagModel and asset rows but does not call `SerializedDagModel.write_dag`,
so that scan is what serializes a newly deployed DAG. Removing or skipping it would
leave deployed pipelines unrunnable.

Tests: `tests/unit/ingestion_pipeline/test_get_dagbag.py` - the bag comes back empty
over a populated folder, `collect_dags` is never called, and `process_file` still
bags the deployed DAG and only that DAG. All three fail before this change.

* fix(airflow-apis): keep the pre-3.0 DagBag path unchanged

`collect_dags` was only added to `DagBag.__init__` in Airflow 2.5 (absent in 2.4.0,
present in 2.5.3), and the plugin declares `apache-airflow>=2.2.2`, so passing it
unconditionally raised `TypeError` on 2.2 through 2.4 and failed every deploy there.

Scope the change to Airflow >= 3.0, which is where the regression is. Below 3.0 the
bag is still built with `read_dags_from_db=True`, which early returns out of
`collect_dags`, so that path never walked the DAG folder and needs no change.

Gate the new tests on Airflow 3 for the same reason.

* fix(airflow-apis): unblock airflow-apis-tests on Airflow 3.3

`TestAirflowOps.setUpClass` passed `include_examples=False` to `DagBag`. Airflow 3.3
dropped that keyword -- DAG discovery is bundle based there, so example DAGs are no
longer a constructor flag -- and Python raises `TypeError` for an unknown keyword.
The call is in class setup, so all three tests in the class error before running.

This is unrelated to the DagBag change in this branch: the test builds its own DagBag
and never calls `get_dagbag`. It broke when the Airflow pin moved from 3.2.2 to 3.3.0
in #31338, and has failed on every branch that reached this job since. Fixed here only
because the job has to be green for this branch to be validated; happy to split it out.

Detect the keyword instead of assuming it, matching the `sync_to_db` and `bag_dag`
compatibility checks already in this setup, so the test keeps working on Airflow 2.x
and on 3.x.

Not changed: the workflow's `paths` filter still only watches
`openmetadata-airflow-apis/**`, so a pin bump in `ingestion/setup.py` cannot trigger
the suite it affects -- which is why this went unnoticed. Widening it would run a
24 minute docker-stack job on a file that changed 26 times in the last 90 days
against this module's 5, so that tradeoff is left to maintainers.

* fix(ops): scale the deploy-pipelines chunk deadline with the chunk size (#31976)

* fix(ops): scale the deploy-pipelines chunk deadline with the chunk size

deploy-pipelines POSTs chunks of pipeline IDs to the bulk deploy endpoint,
which registers each pipeline sequentially, but bounded the request with a
fixed 2 minute deadline. At the default chunk size of 20 that budgets 6
seconds per pipeline, which a freshly restarted pipeline service does not
meet, so the client abandoned requests whose work was still progressing.

A client deadline does not cancel the server, so the abandoned chunk kept
deploying while the command marked all 20 pipelines FAILED and exited 1. A
Kubernetes restartPolicy of OnFailure then replayed the whole run on top of
work still in flight, adding load to an operation that was already
succeeding. On a catalog of 92 pipelines this reported failure while 90 were
deployed.

Budget the deadline per pipeline and multiply by the chunk size, so it no
longer silently becomes too short as a catalog grows, and expose the chunk
size and the per-pipeline budget as options. The command previously accepted
none, so neither value was reachable from a deployment configuration.

Extract the deadline calculation and the failure check as static functions so
the scaling and the exit code are unit testable without a database.

Reporting is left unchanged: an abandoned chunk is still recorded as failed.
The persisted deployed flag cannot correct it, because the deploy path only
ever sets it to true and never resets it, so it records whether a pipeline was
ever deployed rather than what this run did. Reading it to clear a timeout
would turn a genuine failure into a silent success on any redeploy. A per-run
answer needs the deploy response itself, which is a separate change.

* fix(ops): reject a non-positive deploy-pipelines chunk size

Exposing --chunk-size made a value that was previously hardcoded to 20
reachable from outside, and chunkList advances its loop with i += chunkSize.
A chunk size of 0 never advances, appending empty chunks until the heap is
exhausted, and a negative size makes subList throw, which the surrounding
handler turns into every pipeline being reported as FAILED.

Validate both options before the deploy runs and report each offending value,
rather than clamping, so a mistyped flag is not silently replaced by a
different deadline. Guard chunkList as well, so a non-positive size fails
loudly instead of spinning if another caller ever skips validation.

A non-positive --seconds-per-pipeline was already safe, since the deadline
floors at the previous fixed 2 minutes, but it is rejected too rather than
silently falling back to the deadline this option exists to move away from.

Drops the deployChunkTimeout(0, 30) assertion, which implied a chunk size of
0 was supported when it now fails validation.

* test(ops): cover picocli binding for the deploy-pipelines options

Parsing the command with picocli asserts the new options bind to the values
passed on the command line and that the declared defaults still match the
20 and 30 the description documents. Neither was covered: the existing tests
call the helpers directly, so a mistyped option name or a default drifting
from its description would not have failed anything.

Reads the defaults from the command spec rather than the parse result, since
matchedOptionValue only reports options actually present on the command line.

Needs no database, so it stays a unit test.

* chore: re-trigger CI after linking issue #32114

* chore: re-trigger CI

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy-pipelines bounds every chunk with a fixed 2-minute deadline that a chunk of 20 cannot meet

2 participants