bundle: validate recorded state size during bundle validate - #6087
bundle: validate recorded state size during bundle validate#6087shreyas-goenka wants to merge 3 commits into
Conversation
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
Integration test reportCommit: d808f7f
11 interesting tests: 4 SKIP, 3 FAIL, 3 RECOVERED, 1 KNOWN
Top 1 slowest tests (at least 2 minutes):
|
Approval status: pending
|
| @@ -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 | |||
There was a problem hiding this comment.
q: can we start with with telemetry here rather than error? why break existing deployments.
There was a problem hiding this comment.
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.
| return 0, fmt.Errorf("cannot prepare state for %s: %w", key, err) | ||
| } | ||
|
|
||
| raw, err := structwalk.RedactSensitiveFields(state, dyn.SensitiveValueRedacted) |
There was a problem hiding this comment.
redaction not needed, will be removed soon.
There was a problem hiding this comment.
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
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.