Repository navigation
Fixes #36586: Defer external service secret writes - #36587
Conversation
Keep preparation free of vault mutations so rejected authorization cannot change credentials. Encrypt through single, versioned, and batch storage paths.
Keep prepared and approval-staged credentials encrypted locally. Persist external secrets only when storage runs, preserving existing ciphertext during preparation.
| @Override | ||
| protected void store(T service, boolean update, Double expectedVersion) { | ||
| encryptConnection(service); | ||
| super.store(service, update, expectedVersion); | ||
| } | ||
|
|
||
| @Override | ||
| protected void storeMany(List<T> services) { | ||
| services.forEach(this::encryptConnection); | ||
| super.storeMany(services); | ||
| } | ||
|
|
||
| @Override | ||
| protected void updateMany(List<T> services) { | ||
| services.forEach(this::encryptConnection); |
There was a problem hiding this comment.
💡 Performance: Vault network writes now run inside the open DB transaction
Before this change, external secrets were written in prepare(), before any database transaction had started. They are now written from store, storeMany and updateMany. Those methods run inside a database transaction: store(T, boolean) is @Transaction, and the bulk paths run inside flushInOneTransaction(...). As a result, every upsertSecret/deleteSecret call to AWS, Azure or GCP happens while the transaction holds its JDBC connection and row locks. That is one remote call for each password field. In a bulk create or update of N services, the transaction stays open for N × fields vault round trips. Under load this can use up the connection pool and lengthen lock waits.
One fix is to work out the encrypted references inside the transaction (storeValue with store=false already returns the secret: reference) and do the vault upserts/deletes in a post-commit hook. Running them after authorization but before the transaction opens would also work. Either way, the stored JSON and the vault would still agree.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 closed / 1 findings🔴 High risk · Deferring external service-secret writes from preparation to single and batch storage hooks could overwrite or lose credentials if a path mishandles them. Defers external service connection secret writes out of preparation and into the storage hooks ( 💡 Performance: Vault network writes now run inside the open DB transactionBefore this change, external secrets were written in One fix is to work out the encrypted references inside the transaction ( 🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Local Java test run: FAILED — details
Failed: Selected but produced no report: Tests run locally
Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts. integration · mysql-elasticsearch · parallel: 50 classes
Why these tests
Impacted, not run locally (1)
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AWSSSMSecretsManagerLocalStackTest,AWSSSMSecretsManagerTest,AWSSecretsManagerLocalStackTest,AWSSecretsManagerTest,AzureKVSecretsManagerTest,BotTokenCacheTest,CreateIngestionPipelineImplTest,DBSecretsManagerTest,DataContractPipelineTokenRefreshTest,ExternalSecretsManagerUnitTest,GCPSecretsManagerTest,IngestionPipelineSecretsTest,KubernetesSecretsManagerTest,NestedSecretConverterCoverageTest,OpenMetadataConnectionBuilderTest,SecretsManagerLifecycleTest,ServiceConnectionPatchTest,ServiceEntitySecretsTest,WorkflowResourceDecryptTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<50 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=UserMetricsResourceIT,WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
Describe your changes
Fixes #36586
Keep service connection preparation free of external vault mutations. Preparation validates and locally encrypts credentials; the storage hooks persist external secrets after authorization. This covers single writes, version-checked updates, and batch inserts and updates.
Existing secret keys and references remain unchanged. Collision handling is separate follow-up work; no migration is required.
Type of change
High-level design
SecretsManager.prepareServiceConnectionConfigprotects prepared and approval-staged credentials with local Fernet encryption, preserving existing ciphertext.ServiceEntityRepositoryperforms external persistence throughstore,storeMany, andupdateManyso every storage path remains encrypted.Explicit plaintext credentials submitted to an external manager count as a replacement and record a connection update, even if their value is unchanged. Reference round trips and identical database-backed credentials remain no-ops. This avoids adding vault read permissions or a secret-equality oracle.
Decision: ADR:2026-10-29-service-connection-secrets-are-written-only-during-storage.
Tests
Use cases covered
Unit tests
The selected run passed 166 tests across 19 unit classes, including all 18
ServiceEntitySecretsTestcases. The initial regression run against unchanged main reproduced premature overwrite and deletion during preparation.The command is
make java_affected_runwith--keep-goingand additional unit classesServiceConnectionPatchTest,ExternalSecretsManagerUnitTest,SecretsManagerLifecycleTest, andDBSecretsManagerTest, to cover patch guards and both encryption modes. A separate JaCoCo 0.8.13 run passed 59 focused tests and covered all 27 added executable source lines (20/20 in ServiceEntityRepository and 7/7 in SecretsManager). Whole-class line coverage in that focused run was 37/158 (23.4%) and 218/366 (59.6%), respectively; these are not full-suite coverage figures.Backend integration tests
All seven
SecretsManagerNullSecretITtests passed, including the new HTTP authorization, approval, and credential replacement regressions. The broader run completed with 3,744 passing integration tests, one workflow-redeployment failure, and 467 skips. The selected TODO-only McpServiceResourceIT has no runnable class and produces no report; that planner cleanup is tracked separately in PR #36553. The failing method, WorkflowRedeploySignalIT#suspendedWorkflowRedeployedTakesNoSignal, passed when rerun alone on both unchanged main at 7843a02 and the PR head (one test passed in each MySQL/Elasticsearch run). The original broader-run failure remains recorded below; it did not reproduce in either isolated rerun. The PR remains draft.Local Java test run: FAILED
abd608fdeb6b(baseorigin/main)Failed:
WorkflowRedeploySignalIT#suspendedWorkflowRedeployedTakesNoSignal(TestNamespace)Selected but produced no report:
McpServiceResourceIT (mysql-elasticsearch · parallel)Ingestion integration tests
Not applicable — no Python ingestion changes.
Playwright and manual testing
No UI changes.
make playwright_affectedwas attempted but dependency expansion could not run because local@playwright/testis unavailable. No Playwright or manual UI tests were run; the service paths are exercised over HTTP by the integration tests.UI screen recording
Not applicable — backend-only change.
Checklist
git diff --checkpass; the Java impact map owns the changed code and tests.abd608fdeb6b8c636ce1d51fb75bd4cdef8ab9f0againstREVIEW.md: no unresolved Important findings. Preparation retains local encryption for approval staging; external replacement behavior is documented and tested.