Repository navigation
fix(ops): scale the deploy-pipelines chunk deadline with the chunk size - #31976
Conversation
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.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
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.
Code Review ✅ Approved 1 resolved / 1 findingsScales 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
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
✅ Playwright Results — workflow succeededValidated commit ✅ 553 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…#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.
#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
Problem
Fixes #32004.
deploy-pipelinesPOSTs chunks of pipeline IDs toPOST /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: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
FAILEDand exits 1 — and a KubernetesrestartPolicy: OnFailurethen 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.
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
DagContextautoregister raisingKeyError: 'unusual_prefix_<hash>_<other dag>'when DAG files parse concurrently. The fix replacedwith DAG(...) as dag:with an explicitdag=reference, andbuild_dagon bothmainand2.0.0-releasealready carries it.This is a different layer and a different symptom — a client-side deadline in the Java ops CLI (
HttpTimeoutExceptionindeployPipelineChunk), not a DAG-parse crash in the pipeline service. And the bulk deploy path has no parallelism to race in the first place (.stream(), synchronousclient.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
--chunk-sizeand--seconds-per-pipeline. The command previously declared no options at all, so neither value was reachable from a deployment configuration (the Helm chart'sdeployPipelinesConfig.additionalArgshad nothing to pass).planSmartReindexpattern.DeployRequestrecord keeps the chunk method within the parameter limit.This is a client-side change only. The
bulk/deployendpoint 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
deployedflag cannot correct it: the deploy path only ever callssetDeployed(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-upgradedeploy-pipelinesalways 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.
deployPipelineChunkswallows 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:The previous deadline budgeted
120s / 20 = 6.0sper 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
504at ~65s, but that is the load balancer's 60s idle timeout rather than a server limit, and does not apply to this command:metadataApiEndpointresolves 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 existingOpenMetadataOperationsSmartReindexTest.mvn spotless:applyclean.Also exercised end to end by invoking the command from this branch against a running server and MySQL:
chunks of 20 with a 600s deadline per chunk, all pipelines deployed, exit 0--chunk-size 3 --seconds-per-pipeline 45chunks of 3 with a 135s deadline per chunk, 2 chunks, every responsecode=200, exit 0--chunk-size 1 --seconds-per-pipeline 5120s, 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 0deploy-pipelines --helpBehaviour is identical on
main,2.0.0-release,origin/1.13and1.13.4-release, so this applies to both release lines and can be picked to1.13.