Skip to content

bundle: validate recorded state size during bundle validate - #6087

Open
shreyas-goenka wants to merge 3 commits into
mainfrom
shreyas-goenka/validate-state-size
Open

bundle: validate recorded state size during bundle validate#6087
shreyas-goenka wants to merge 3 commits into
mainfrom
shreyas-goenka/validate-state-size

Conversation

@shreyas-goenka

@shreyas-goenka shreyas-goenka commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Changes

This is a best effort and slightly in-perfect validation to error early if we detect users will have really large state sizes. Rather than failing at runtime.

The deployment metadata service rejects a resource state over 64 KiB
(MAX_STATE_BYTES) with InvalidArgument. Hitting that mid-apply fails a deploy
after some resources have already been created, so check it up front instead.

The state checked here is what the deploy path uploads: the state prepared from
config, serialized with sensitive fields redacted. It is a pure config
transform, so it needs no workspace request and belongs in FastValidate, which
runs for both `bundle validate` and `bundle deploy`.

The check is scoped to direct-engine deployments that opted into
experimental.record_deployment_history, since no other deployment uploads this
state. FastValidate now takes the resolved engine rather than reading
bundle.engine, which reports terraform when DATABRICKS_BUNDLE_ENGINE selects it.

Co-authored-by: Isaac
"Split it up" means a different edit per resource type, so name the split that
applies: multiple jobs with fewer tasks, multiple alerts with fewer conditions,
multiple pipelines with fewer libraries.

file_path on alerts (and dashboards/genie spaces) is deliberately not suggested.
LoadDBAlertFiles inlines the file into AlertV2 during initialize, so the recorded
state is byte-identical whether the body came from file_path or from inline YAML;
recommending it would send users on a refactor that does not reduce the size.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: d808f7f

Run: 30461623052

Env ❌​FAIL 🟨​KNOWN 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
❌​ aws linux 3 1 3 4 319 1066 5:30
❌​ aws windows 3 1 3 4 321 1064 8:52
❌​ azure linux 3 1 3 4 319 1065 5:31
❌​ azure windows 3 1 3 4 321 1063 9:07
💚​ gcp linux 1 5 321 1067 5:23
💚​ gcp windows 1 5 323 1065 7:15
11 interesting tests: 4 SKIP, 3 FAIL, 3 RECOVERED, 1 KNOWN
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
🟨​ TestAccept 🟨​K 🟨​K 🟨​K 🟨​K 💚​R 💚​R
❌​ TestAccept/bundle/deploy/mlops-stacks ❌​F ❌​F ❌​F ❌​F ✅​p ✅​p
❌​ TestAccept/bundle/deploy/mlops-stacks/DATABRICKS_BUNDLE_ENGINE=direct ❌​F ❌​F ❌​F ❌​F ✅​p ✅​p
❌​ TestAccept/bundle/deploy/mlops-stacks/DATABRICKS_BUNDLE_ENGINE=terraform ❌​F ❌​F ❌​F ❌​F ✅​p ✅​p
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R
Top 1 slowest tests (at least 2 minutes):
duration env testname
5:28 gcp windows TestAccept

@shreyas-goenka
shreyas-goenka marked this pull request as ready for review July 28, 2026 16:21
@github-actions

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

5 files changed
Suggested: @denik
Also eligible: @pietern, @andrewnester, @janniklasrose, @lennartkats-db, @anton-107

/bundle/ - needs approval

4 files changed
Suggested: @denik
Also eligible: @pietern, @andrewnester, @janniklasrose, @lennartkats-db, @anton-107

/cmd/bundle/ - needs approval

Files: cmd/bundle/utils/process.go
Suggested: @denik
Also eligible: @pietern, @andrewnester, @janniklasrose, @lennartkats-db, @anton-107

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @simonfaltum, @renaudhartert-db, @janniklasrose, @lennartkats-db) can approve all areas.
See OWNERS for ownership rules.

@@ -0,0 +1,18 @@

>>> [CLI] bundle validate
Error: resources.jobs.oversized has a serialized state of 70278 bytes, which exceeds the 65536 byte limit for recording deployment history

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: can we start with with telemetry here rather than error? why break existing deployments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation is DMS only. Will not break existing yet.

can we start with with telemetry here rather than error?

We have telemetry. Defintiely jobs that are larger (800KB ish) exist.

Comment thread bundle/config/validate/state_size.go Outdated
return 0, fmt.Errorf("cannot prepare state for %s: %w", key, err)
}

raw, err := structwalk.RedactSensitiveFields(state, dyn.SensitiveValueRedacted)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redaction not needed, will be removed soon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d808f7f — switched to plain json.Marshal. Redaction only swapped secret strings for a fixed-width placeholder, so the byte count is unchanged (acceptance output is byte-identical), and this no longer depends on the code path being removed.

Redaction is being removed, so measuring through RedactSensitiveFields would
couple this check to a code path on its way out. Plain json.Marshal is what the
size measurement actually needs: redaction swaps secret strings for a fixed
placeholder, which does not meaningfully change the byte count either way.

Addresses review feedback on #6087.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants