Repository navigation
Fixes 24806: refresh the Data Contract DQ DAG deployment on every validation - #31848
Conversation
Fixes open-metadata#24806. The bot JWT reaches Airflow exactly once: DagDeployer.store_airflow_pipeline_config serialises openMetadataServerConnection.securityConfig.jwtToken into DAG_GENERATED_CONFIGS/<dag_id>.json at deploy time, and the generated DAG reads that file on every parse. Nothing rewrites it afterwards. deployAndTriggerDQValidation guarded the redeploy behind !pipeline.getDeployed(), so a data contract deployed once at creation never redeployed again and kept authenticating with the token it was born with. Rotating testsuite-bot's JWT could not reach the DAG. Other pipeline types escape this because requiresRedeployment fires when the user edits the pipeline; editing a DataContract never touches the pipeline's airflowConfig, enabled, sourceConfig or loggerLevel. prepareAndRunIngestionPipeline did rebuild a fresh connection, but AirflowRESTClient. runPipeline posts only {dag_id}, so that connection never left the server. /validate now always redeploys before triggering, which rewrites the DAG config with a freshly minted token and makes a rotated token self-healing. Refreshing an already deployed pipeline is best-effort: a pipeline-service outage logs a warning and still triggers the previously deployed DAG, so an installation that worked before cannot start failing. A never-deployed pipeline still propagates the deploy failure. The masked window is only the deploy HTTP call, because the connection is rebuilt again outside the catch and a bot or secrets-manager failure is rethrown there. The !alreadyDeployed guard on the follow-up write does not remove an existing write: pre-fix that path never reached prepareAndDeployIngestionPipeline at all. It keeps the refactor from introducing a new one, whose real cost is storeEntity -> encryptIngestionPipeline -> encryptPasswordFields(store=true), an external secrets-manager write on AWS SM / Parameter Store, to persist a deployed flag that is already true. Boolean.TRUE.equals also makes the check null-safe, where !getDeployed() would have NPEd on a legacy row with a null flag. K8sPipelineClient.runPipeline rebuilds the job and its bot token on every run, so the k8s/Argo runner never had this bug. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
… not cover Review feedback on open-metadata#31848: the javadoc asserted that a failed refresh always leaves the previously deployed DAG runnable. DagDeployer.deploy() truncates <dag_id>.json and <dag_id>.py in place and validates afterwards, so a write that fails part way through can leave a half-written artifact and that assertion does not hold. Behaviour is unchanged. The fallback is still correct for every failure that is decided before Airflow rewrites the artifacts - transport failures, a payload the deploy endpoint rejects, and a DagBag reparse failure, which only happens after both files are fully written with the new token. The partial-write hazard is not introduced by this PR (pipeline create/update and /ingestionPipelines/deploy/{id} run the same non-atomic code); this is only the first caller that does not propagate it, so the javadoc now says so instead of claiming safety it does not have. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013D3LpP12bP6RBF2tFo5Rmn
There was a problem hiding this comment.
🟡 Changes recommended
The new “redeploy on every validation” path is currently unconditional across pipeline clients (not Airflow-specific) and the best-effort failure log drops stack traces, creating avoidable operational churn and diagnosability gaps.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
| private void refreshDeployedPipelineBeforeRun(IngestionPipeline pipeline, TestSuite testSuite) { | ||
| boolean alreadyDeployed = Boolean.TRUE.equals(pipeline.getDeployed()); | ||
| try { | ||
| prepareAndDeployIngestionPipeline(pipeline, testSuite); | ||
| } catch (RuntimeException e) { |
There was a problem hiding this comment.
Both valid, both fixed in 53ecd19. Thanks — the churn is worse than you describe.
Gating. You're right that the pinning is Airflow's alone: AirflowRESTClient.runPipeline posts only {dag_id}, so the token can only reach an already-deployed DAG via another deploy. K8sPipelineClient.runPipeline inlines a freshly built config into ENV_CONFIG (buildEnvVars → buildCommonIngestionEnvVars(..., includeConfig=true) → buildWorkflowConfigWithOverrides(pipeline, ...)), and Collate's ArgoServiceClient.runPipeline rebuilds the whole Workflow spec through WorkflowConfigBuilder, which reads ingestionPipeline.getOpenMetadataServerConnection() per call. Both already carry the current token.
And the wasted work is specifically wasted: a data contract's DQ pipeline is created with a bare new AirflowConfig() (DataContractRepository:987), so scheduleInterval is null. That means k8s wrote an om-config-/om-secret- pair that only the CronJob path ever reads (buildEnvVarsForCronJob via configMapKeyRef) — so on an unscheduled pipeline nothing consumes them at all — and Argo took its unscheduled branch, which calls cleanCronWorkflow(), i.e. issued a CronWorkflow delete per validation. With DataContractValidationApp sweeping every contract nightly that was N of each per day.
I went with a capability on PipelineServiceClientInterface rather than a className check:
default boolean pinsCredentialsAtDeployTime() { return false; }overridden to true in AirflowRESTClient only. It states why a runner needs the refresh instead of naming a vendor, and the false default is the correct answer for every other implementation — including out-of-tree ones, which keep compiling untouched. One trap worth noting: MeteredPipelineServiceClient is a decorator, so it has to delegate the method; without that it would have answered false for Airflow and silently disabled the whole fix. Non-pinning runners now keep the exact pre-refresh behaviour — deploy only when nothing is deployed yet.
Log. Fixed, e is now passed as the trailing arg so the stack trace is emitted alongside the message.
Tests. validateDoesNotRedeployARunnerThatRebuildsTheTokenOnEveryRun fails without the gate:
org.opentest4j.AssertionFailedError: expected: <[]> but was: <[stale-jwt-token, rotated-jwt-token]>
plus one pinning the first deploy still happening on a non-pinning runner. The four existing tests needed when(client.pinsCredentialsAtDeployTime()).thenReturn(true) — Mockito's default of false would otherwise have disabled the behaviour under test, which is the same trap as the decorator. 159/159 green across DataContractPipelineTokenRefreshTest, AirflowRESTClientTest, K8sPipelineClientTest, IngestionPipelineRepositoryTest, PipelineTaskKeyTest, OpenMetadataConnectionBuilderTest.
Out of scope but worth an issue: the scheduled paths do pin the token — Argo's CronWorkflow spec and k8s's om-config-/om-secret- objects are written at deploy time and only rewritten on redeploy. Same bug class as #24806 reached through a different trigger. Not touched here, since contract validation goes through runPipeline.
There was a problem hiding this comment.
🔵 Needs a closer look
It changes validation-time operational behavior by introducing per-validation redeploy calls (with best-effort failure semantics) and should get a final human review focused on runtime/scale impact and external-dependency failure modes.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
Code Review ✅ Approved 2 resolved / 2 findingsFixes token pinning in Data Contract DQ DAG deployments by redeploying the pipeline before every validation so Airflow receives the current bot token, with best-effort semantics for already-deployed contracts. Addresses the redeploy multiplying load in the nightly sweep and the deploy-failure WARN omitting exceptions as known trade-offs. Comprehensive unit tests added covering token rotation, triggering, and deployment-failure behavior with 81.8% line coverage on changed methods. ✅ 2 resolved✅ Performance: Redeploy on every validate multiplies load in nightly sweep
✅ Quality: Deploy-failure WARN omits exception, hiding root cause
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 |
|
285932f
…idation (open-metadata#31848) * fix(data-contract): refresh the DQ DAG deployment on every validation Fixes open-metadata#24806. The bot JWT reaches Airflow exactly once: DagDeployer.store_airflow_pipeline_config serialises openMetadataServerConnection.securityConfig.jwtToken into DAG_GENERATED_CONFIGS/<dag_id>.json at deploy time, and the generated DAG reads that file on every parse. Nothing rewrites it afterwards. deployAndTriggerDQValidation guarded the redeploy behind !pipeline.getDeployed(), so a data contract deployed once at creation never redeployed again and kept authenticating with the token it was born with. Rotating testsuite-bot's JWT could not reach the DAG. Other pipeline types escape this because requiresRedeployment fires when the user edits the pipeline; editing a DataContract never touches the pipeline's airflowConfig, enabled, sourceConfig or loggerLevel. prepareAndRunIngestionPipeline did rebuild a fresh connection, but AirflowRESTClient. runPipeline posts only {dag_id}, so that connection never left the server. /validate now always redeploys before triggering, which rewrites the DAG config with a freshly minted token and makes a rotated token self-healing. Refreshing an already deployed pipeline is best-effort: a pipeline-service outage logs a warning and still triggers the previously deployed DAG, so an installation that worked before cannot start failing. A never-deployed pipeline still propagates the deploy failure. The masked window is only the deploy HTTP call, because the connection is rebuilt again outside the catch and a bot or secrets-manager failure is rethrown there. The !alreadyDeployed guard on the follow-up write does not remove an existing write: pre-fix that path never reached prepareAndDeployIngestionPipeline at all. It keeps the refactor from introducing a new one, whose real cost is storeEntity -> encryptIngestionPipeline -> encryptPasswordFields(store=true), an external secrets-manager write on AWS SM / Parameter Store, to persist a deployed flag that is already true. Boolean.TRUE.equals also makes the check null-safe, where !getDeployed() would have NPEd on a legacy row with a null flag. K8sPipelineClient.runPipeline rebuilds the job and its bot token on every run, so the k8s/Argo runner never had this bug. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs(data-contract): state what the best-effort refresh fallback does not cover Review feedback on open-metadata#31848: the javadoc asserted that a failed refresh always leaves the previously deployed DAG runnable. DagDeployer.deploy() truncates <dag_id>.json and <dag_id>.py in place and validates afterwards, so a write that fails part way through can leave a half-written artifact and that assertion does not hold. Behaviour is unchanged. The fallback is still correct for every failure that is decided before Airflow rewrites the artifacts - transport failures, a payload the deploy endpoint rejects, and a DagBag reparse failure, which only happens after both files are fully written with the new token. The partial-write hazard is not introduced by this PR (pipeline create/update and /ingestionPipelines/deploy/{id} run the same non-atomic code); this is only the first caller that does not propagate it, so the javadoc now says so instead of claiming safety it does not have. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013D3LpP12bP6RBF2tFo5Rmn * fix(data-contract): only refresh runners that pin credentials at deploy time Review feedback on open-metadata#31848: the refresh fired for every PipelineServiceClient implementation, but the pinned-JWT problem is Airflow's alone. AirflowRESTClient. runPipeline posts only the dag_id, so the token can only reach an already deployed DAG through another deploy. K8sPipelineClient.runPipeline inlines a freshly built workflow config into ENV_CONFIG and Collate's ArgoServiceClient rebuilds the whole Workflow spec via WorkflowConfigBuilder, so both already carry the current token on every run. Re-deploying those was therefore pure churn for a problem they do not have, and not free: a data contract's DQ pipeline is created with a bare AirflowConfig and so has no scheduleInterval, which means k8s wrote a ConfigMap and a Secret that only the CronJob path ever reads, and Argo took its unscheduled branch and issued a CronWorkflow delete. DataContractValidationApp sweeps every contract nightly, so that was N of each per day. Expressed as a capability on PipelineServiceClientInterface rather than a check on the configured className, so it says why a runner needs the refresh instead of naming a vendor. The default is false, which is the correct answer for every implementation except Airflow - including out-of-tree ones, which keep compiling untouched. MeteredPipelineServiceClient delegates it; without that the decorator would silently answer false for Airflow and disable the fix. Non-pinning runners keep the pre-refresh behaviour of deploying only when nothing is deployed yet. Also log the exception, not just its message, so a persistent refresh failure is diagnosable. Tests: two added. validateDoesNotRedeployARunnerThatRebuildsTheTokenOnEveryRun fails without the gate with expected <[]> but was <[stale-jwt-token, rotated-jwt-token]>. The existing four needed the mock stubbed to true, since a Mockito default of false would have disabled the fix under test. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013D3LpP12bP6RBF2tFo5Rmn --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>



Describe your changes:
Fixes #24806
A Data Contract's DQ Airflow DAG keeps authenticating with the bot JWT that was current the moment
the contract was first created. Rotating or re-issuing the
testsuite-bottoken never reaches theDAG, so every later validation fails with
SigningKeyNotFoundException, and there was no server-sidepath a contract user could hit to refresh it.
I made
POST /v1/dataContracts/{id}/validatealways re-deploy the DQ pipeline before triggering it,so a contract run rewrites the DAG config with a freshly minted token and is self-healing — the
"Expected behavior" the issue asks for.
Type of change:
High-level design:
Where the token is pinned. The JWT reaches Airflow exactly once, when the DAG config JSON is
written at deploy time:
DagDeployer.store_airflow_pipeline_config(
openmetadata-airflow-apis/.../operations/deploy.py:92) →dump_with_safe_jwt(:50), whichserialises
openMetadataServerConnection.securityConfig.jwtTokenintoDAG_GENERATED_CONFIGS/<dag_id>.json. The generated DAG re-reads that file on every Airflow parse(
workflows/workflow_factory.py), andworkflows/ingestion/test_suite.pycopies the connectionstraight into
workflowConfig. That file is the pin.Everything upstream of it was already correct. The token is never persisted on the entity —
IngestionPipelineRepository.getFieldsStrippedFromStorageJson()stripsopenMetadataServerConnectionfrom the storage JSON — andOpenMetadataConnectionBuilderrebuildsit from the bot's current DB row on every call, resolving
TEST_SUITE→testsuite-bot.The single gate.
DataContractRepository.deployAndTriggerDQValidationguarded the redeploybehind
if (!pipeline.getDeployed()). Oncedeployed == true,prepareAndDeployIngestionPipelinewas never invoked again for the life of the contract, so the DAG config was written once at creation
and never rewritten.
Why other pipeline types were unaffected.
IngestionPipelineRepository.requiresRedeploymenttriggers a redeploy on schedule /
enabled/sourceConfig/loggerLevelchanges. For a metadataor profiler agent the user edits the pipeline, so the token gets refreshed as a silent side effect.
For a data contract the user edits the DataContract entity, which mutates the TestSuite but never
touches the pipeline's
airflowConfig/enabled/sourceConfig/loggerLevel— sorequiresRedeploymentreturnedfalseevery time.k8s/Argo was never affected.
K8sPipelineClient.runPipelinerebuilds the job from the passedpipeline on every run and re-derives the bot token, so it has no equivalent pinned artifact.
prepareAndRunIngestionPipelinebuilds afresh
OpenMetadataConnectionon every validate, which looks like the refresh already works. Itdoes not:
AirflowRESTClient.runPipelineposts only{dag_id}(plus an optionalconfoverride),so that connection never leaves the server. Only
deployPipelineposts the fullIngestionPipelinePOJO, which is what carries the JWT.
A second non-obvious constraint, now guarded by an inline comment. The two
refreshOpenMetadataServerConnectioncalls look like duplication and are not. On a first deploy thefollow-up
createOrUpdaterunsstoreEntity→SecretsManager.encryptIngestionPipeline, which atSecretsManager.java:317replaces the pipeline'sopenMetadataServerConnectionwith thestore=trueform and writes it back onto the live object at:330— a secret reference rather thanthe token on an external secrets manager. The rebuild in
prepareAndRunIngestionPipelineis whatputs the usable form back before the runner reads it. Folding the two calls into one at the top of
deployAndTriggerDQValidationis tempting and would be wrong.Deliberate failure semantics. The refresh is best-effort for an already deployed pipeline
(deploy failure logs
WARNand still triggers the existing DAG) and strict for a never-deployedone (failure propagates). Strict propagation everywhere would be wrong: it would convert a
transient Airflow blip into a new validation failure on installations that work today, whereas
triggering the previously deployed DAG is exactly the pre-fix behaviour. The masked window is
narrower than the
catchsuggests —refreshOpenMetadataServerConnectionruns again outside thetry, so a missingtestsuite-botor aSecretsManagerExceptionis logged and then immediatelyrethrown two lines later, marking the result
Aborted. Only the deploy HTTP call is genuinelyswallowed.
Cost. Per validation of a contract with quality expectations:
POST <airflow>/deploy, which is not free server-side (deploy.py:176-186runsstore_airflow_pipeline_config+store_and_validate_dag_file+dag_bag.process_file+dag.sync_to_db+scan_dags_job_background());OpenMetadataConnectionBuilderconstructions → 2× bot read, 2× user read, 2× JWT decrypt (aremote secret read on an external secrets manager), per the constraint above;
the
&& !alreadyDeployedguard keeps the refactor from introducing acreateOrUpdateon everyvalidation, whose real cost would be
storeEntity→encryptIngestionPipeline→encryptPasswordFields(store=true), to persist adeployedflag that is alreadytrue.Fan-out — please size this before merge. This is not only user-initiated.
DataContractValidationApp(seeded fromjson/data/app/DataContractValidationApplication.json,cron
0 0 * * *) paginates every data contract in the installation in batches of 100 and callsvalidateContracton each, plus a second sweep over data-product assets callingvalidateContractWithEffective. So the extra deploy is N per day for N contracts, serially — notper click. I judged this acceptable (it is the same call
/ingestionPipelines/deploy/{id}alreadymakes, and it is what makes the fix self-healing with no user present), but it is worth a look from
someone who knows large-deployment contract counts.
What is NOT fixed. The issue lists three acceptable outcomes; the third — "saving a contract
should regenerate the DAG configuration" — remains unmet.
requiresRedeploymentstill ignorescontract-driven edits, so the refresh happens on
/validateonly. In practice a rotated token healswithin ≤24h unattended via the nightly app, or immediately on a manual Run Now, but not at the
moment the user saves the contract. Adding a Redeploy button to the contract UI (the other
alternative the issue mentions) is also not included.
Recommended follow-up (not done here). A persistent
/deployfailure on an already-deployedcontract is only visible as a
WARNinopenmetadata.logwhile validations keep failing against thestale DAG — the exact symptom of this issue, with the cause hidden. Surfacing it on
DataContractResult.getResult()so the UI shows "DQ DAG could not be refreshed" would fix that, butdeployAndTriggerDQValidationisvoidand its two callers each construct their ownDataContractResult, so it is an observable behaviour change that deserves its own issue rather thanriding along on a scoped bug fix.
Tests:
Use cases covered
testsuite-botJWT; the next Data Contract validation re-deploys the DAG soit authenticates with the new token instead of the pinned one.
validation still triggers the previously deployed DAG rather than failing.
fails loudly instead of triggering a DAG that does not exist.
Unit tests
I added unit tests for the new/changed logic.
Files added:
openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/DataContractPipelineTokenRefreshTest.java(4 tests)Coverage on the changed methods (
mvn jacoco:report, from this test class alone):refreshDeployedPipelineBeforeRunrefreshOpenMetadataServerConnectionprepareAndRunIngestionPipelineprepareAndDeployIngestionPipelinedeployAndTriggerDQValidationBelow the 90% target, and I would rather explain than pad it. The 8 uncovered lines are all
pre-existing and unreachable from a unit test: 6 are the two guard-clause
throws indeployAndTriggerDQValidation(no test suite / no pipelines), and 2 aresetDeployed(true)+createOrUpdate— which need a real JDBI handle. Whole-class coverage ofDataContractRepositoryfrom this class alone is ~4%, which is not a meaningful number: the classis 1,856 lines and these tests deliberately exercise only the validate path.
How the tests assert. Every assertion is on the payload that reaches the
PipelineServiceClientInterfaceboundary — recorded into aList<String>by athenAnswerstub —so they test what actually leaves the server rather than internal call wiring. There is no
verify()anywhere in the class.DataContractRepositoryandIngestionPipelineRepositoryarereal instances; only the pipeline-service client (a genuine external boundary) is mocked. The bot's
token comes from a stubbed repository read backed by a mutable field, so the headline test rotates
the token mid-test and asserts the second deploy payload carries the new value.
Honest RED status: only one of the four fails without the fix.
validateRefreshesTheDeployedDagWithTheCurrentBotToken— fails pre-fix, and is the actualregression proof:
<[]>is the bug: two validations of an already-deployed contract with the token rotated inbetween, and not one deploy payload ever reached the pipeline service.
the run path; they are not evidence of the bug and I am not presenting them as such.
Backend integration tests
/validatealready existed; only its internalbehaviour changed).
deployAndTriggerDQValidationhas no pre-existing IT coverage,and this specific behaviour cannot be asserted from an IT today — the IT harness wires a real
AirflowRESTClientagainst no Airflow with no recording fake, so the deploy payload is notobservable. That is why the regression test is a unit test. I did run the one existing IT that
creates a contract with
qualityExpectations(and therefore exercises the pipeline create +deploy path) as a non-regression check:
DataContractResourceIT#testDataContractCreatesReverseTestSuiteRelationship→ 1/1 pass.Ingestion integration tests
defect; no file under
ingestion/oropenmetadata-airflow-apis/was modified.Playwright (UI) tests
Manual testing performed ✅
(
AIRFLOW__OPENMETADATA_AIRFLOW_APIS__DAG_GENERATED_CONFIGS; dev default/opt/airflow/dag_generated_configs).case under Quality Expectations. This deploys the DAG once.
By API, note these live under
/v1/users(not/v1/bots), take the id in the requestbody, and need the bot's User id — not the Bot entity id:
TOKEN_B != TOKEN_A.main). Re-run the validation (Run Now, orPOST /api/v1/dataContracts/{id}/validate).<dag_id>.jsonstill holds TOKEN_A, mtimeunchanged, and the DAG run fails to authenticate.
<dag_id>.jsonnow holds TOKEN_B and themtime has advanced.
Runningrather than hanging or logging an auth error./validateon the samealready-deployed contract, and check for
Could not refresh DQ pipeline '<fqn>' before validation, running the DAG already deployed:—the validation must proceed to the trigger rather than aborting at the deploy step.
Automated gates that were run (real output):
Not run: the full
openmetadata-serviceunit suite and the fullDataContractResourceIT.UI screen recording / screenshots:
Not applicable — backend-only change, no UI files touched.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.DataContractPipelineTokenRefreshTest#validateRefreshesTheDeployedDagWithTheCurrentBotTokencarries issue Dag configs - jwtToken - cannot get updated in Data Contract Dags #24806 in the class Javadoc for future reference.
🤖 Generated with Claude Code
Greptile Summary
This PR refreshes a data contract's DQ pipeline deployment before every validation so Airflow receives the current bot token, while retaining strict first-deploy and best-effort redeploy semantics.
Confidence Score: 4/5
The PR should not merge until the refresh-failure path stops assuming that a failed Airflow deployment leaves the previous DAG artifacts intact.
Airflow can fail after overwriting the configuration or DAG file, while the new catch suppresses that failure and proceeds to trigger an artifact set that may no longer represent the previous valid deployment.
Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataContractRepository.java
Important Files Changed
Sequence Diagram
sequenceDiagram participant V as Contract validation participant S as Metadata service participant A as Airflow deploy API participant F as DAG artifacts V->>S: Validate contract S->>S: Rebuild current bot connection S->>A: Deploy full pipeline A->>F: Overwrite config JSON A->>F: Overwrite and validate DAG file alt Deployment succeeds A-->>S: 200 OK else Later deployment step fails A-->>S: Error S->>S: Suppress error for deployed pipeline end S->>A: Trigger DAGReviews (1): Last reviewed commit: "fix(data-contract): refresh the DQ DAG d..." | Re-trigger Greptile
Context used: