diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/databricks.yml b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/databricks.yml new file mode 100644 index 00000000000..44996a4e040 --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/databricks.yml @@ -0,0 +1,15 @@ +bundle: + name: test-bundle + uuid: 11111111-2222-3333-4444-555555555555 + +# Restrict the sync to a single file under src/ so the file upload (and thus the +# forced failure below) is deterministic and does not sweep up acceptance-harness +# files written during the run. +sync: + paths: + - src + +resources: + jobs: + job_one: + name: job one diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/out.test.toml b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/out.test.toml new file mode 100644 index 00000000000..ae800809893 --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/output.txt b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/output.txt new file mode 100644 index 00000000000..5e035249945 --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/output.txt @@ -0,0 +1,29 @@ + +>>> [CLI] bundle deploy +Error: Failed to acquire deployment lock: Internal error +Error: Internal error (500 INTERNAL_ERROR) + +Endpoint: POST [DATABRICKS_URL]/api/2.0/workspace-files/import-file/Workspace%2FUsers%2F[USERNAME]%2F.bundle%2Ftest-bundle%2Fdefault%2Fstate%2Fdeploy.lock?overwrite=false +HTTP Status: 500 Internal Server Error +API error_code: INTERNAL_ERROR +API message: Internal error + + +Exit code: 1 + +>>> cat out.requests.txt + +=== resources_metadata is reported without state_engine on a failed deploy +>>> cat telemetry.json +{ + "resources": [ + { + "resource_type": "jobs", + "count": 1 + } + ] +} + +=== state_engine is null even though the engine was resolved before the failure +>>> cat telemetry.json +null diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/script b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/script new file mode 100644 index 00000000000..b7cc50d291b --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/script @@ -0,0 +1,16 @@ +errcode trace $CLI bundle deploy + +trace cat out.requests.txt | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson' > telemetry.json + +# resources_metadata is present (per-type counts come from the config), but there is +# no state_engine key: the deploy failed before deployCore ran, so b.Metrics.StateEngine +# is still the zero value and its omitempty drops it. This absence is the "unknown +# engine" the dashboard reports for failed/cancelled deploys. +title "resources_metadata is reported without state_engine on a failed deploy" +trace cat telemetry.json | jq '.entry.databricks_cli_log.bundle_deploy_event.resources_metadata' + +title "state_engine is null even though the engine was resolved before the failure" +trace cat telemetry.json | jq '.entry.databricks_cli_log.bundle_deploy_event.resources_metadata.state_engine' + +rm out.requests.txt +rm telemetry.json diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/src/file.txt b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/src/file.txt new file mode 100644 index 00000000000..ce013625030 --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/src/file.txt @@ -0,0 +1 @@ +hello diff --git a/acceptance/bundle/telemetry/deploy-failed-engine-unknown/test.toml b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/test.toml new file mode 100644 index 00000000000..1b486213722 --- /dev/null +++ b/acceptance/bundle/telemetry/deploy-failed-engine-unknown/test.toml @@ -0,0 +1,23 @@ +# Reproduces the "unknown engine" deploy telemetry. +# +# A deploy that fails before it starts applying resources (here it fails while +# acquiring the deployment lock) still emits a bundle_deploy_event via the deferred +# LogDeployTelemetry in cmd/bundle/utils/process.go. But b.Metrics.StateEngine is +# assigned only inside deployCore (bundle/phases/deploy.go), which never runs on this +# path, so it is still the zero value. resources_metadata is therefore reported with +# per-type counts (which come from the config) but with no state_engine field, and +# the dashboard surfaces that null as engine="unknown" - even though the engine was +# fully resolved (ResolveEngineSetting) long before the deploy failed. +# +# The output is engine-agnostic: the lock is acquired in the shared deploy phase +# before any engine-specific plan/apply, and a failed deploy records no per-resource +# state sizes for either engine. +# +# The stubbed endpoint is the one the workspace filer writes through, so the first +# write - the deploy.lock file in lock.Acquire - is what fails here. +Cloud = false + +[[Server]] +Pattern = "POST /api/2.0/workspace-files/import-file/{path...}" +Response.StatusCode = 500 +Response.Body = '''{"error_code": "INTERNAL_ERROR", "message": "Internal error"}'''