diff --git a/acceptance/bundle/config-remote-sync/json_status_selectors/output.txt b/acceptance/bundle/config-remote-sync/json_status_selectors/output.txt index 2b13979059e..c68bfcfd69c 100644 --- a/acceptance/bundle/config-remote-sync/json_status_selectors/output.txt +++ b/acceptance/bundle/config-remote-sync/json_status_selectors/output.txt @@ -7,6 +7,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged { "status": "skipped", "error": "no deployed jobs resource with id no-such-id-999; deployed jobs ids in state: [TEST_JOB_ID]", + "errorCode": "NO_MATCHING_SELECTOR", "files": null, "changes": {} } diff --git a/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/databricks.yml b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/databricks.yml new file mode 100644 index 00000000000..50f1b73391d --- /dev/null +++ b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/databricks.yml @@ -0,0 +1,11 @@ +bundle: + name: config-remote-sync-no-matching-selector + +resources: + jobs: + foo: + name: test job + tasks: + - task_key: main + notebook_task: + notebook_path: /Workspace/Users/tester@databricks.com/notebook diff --git a/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/out.test.toml b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/out.test.toml new file mode 100644 index 00000000000..aadf9e4a151 --- /dev/null +++ b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/output.txt b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/output.txt new file mode 100644 index 00000000000..b5459f4ae50 --- /dev/null +++ b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/output.txt @@ -0,0 +1,21 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/config-remote-sync-no-matching-selector/default/files... +Created jobs.foo +Files: 1 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> [CLI] bundle config-remote-sync --select-ids jobs:999999 -o json +{ + "status": "skipped", + "error": "no deployed jobs resource with id 999999; deployed jobs ids in state: [FOO_ID]", + "errorCode": "NO_MATCHING_SELECTOR", + "files": null, + "changes": {} +} + +>>> cat [OUTPUT_DIR]/out.requests.txt +{ + "error_message": "no deployed jobs resource with id 999999; deployed jobs ids in state: [FOO_ID]", + "error_category": "NO_MATCHING_SELECTOR" +} diff --git a/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/script b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/script new file mode 100644 index 00000000000..311fa0e0a60 --- /dev/null +++ b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/script @@ -0,0 +1,9 @@ +trace $CLI bundle deploy +read_id.py foo > /dev/null + +# No deployed job has this id, so the sync is skipped rather than failed. +trace $CLI bundle config-remote-sync --select-ids "jobs:999999" -o json + +trace cat "$OUT_REQUESTS" | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null) | {error_message, error_category}' + +rm "$OUT_REQUESTS" diff --git a/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/test.toml b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/test.toml new file mode 100644 index 00000000000..97b2a8e4d49 --- /dev/null +++ b/acceptance/bundle/telemetry/config-remote-sync-no-matching-selector/test.toml @@ -0,0 +1,2 @@ +# config-remote-sync is not supported on Windows. +GOOS.windows = false diff --git a/cmd/bundle/config_remote_sync.go b/cmd/bundle/config_remote_sync.go index 972810d6f0f..6aaea93fcd6 100644 --- a/cmd/bundle/config_remote_sync.go +++ b/cmd/bundle/config_remote_sync.go @@ -114,6 +114,10 @@ Examples: // changes are restricted to the selected resources. selected, err := configsync.ResolveResourceSelectors(ctx, &deployBundle.StateDB, selectIDs) if err != nil { + // Reported as skipped in JSON output, so it must not count as a load failure. + if errors.Is(err, configsync.ErrNoMatchingSelector) { + stats.ErrorCategory = protos.BundleConfigRemoteSyncErrorCategoryNoMatchingSelector + } return err } // A selected resource planned as a delete was renamed or removed in the diff --git a/libs/telemetry/protos/bundle_config_remote_sync.go b/libs/telemetry/protos/bundle_config_remote_sync.go index a62a823c64e..edb7b80eeab 100644 --- a/libs/telemetry/protos/bundle_config_remote_sync.go +++ b/libs/telemetry/protos/bundle_config_remote_sync.go @@ -12,6 +12,7 @@ const ( BundleConfigRemoteSyncErrorCategorySaveFailed BundleConfigRemoteSyncErrorCategory = "SAVE_FAILED" BundleConfigRemoteSyncErrorCategoryOutputFailed BundleConfigRemoteSyncErrorCategory = "OUTPUT_FAILED" BundleConfigRemoteSyncErrorCategoryResourceNotInConfig BundleConfigRemoteSyncErrorCategory = "RESOURCE_NOT_IN_CONFIG" + BundleConfigRemoteSyncErrorCategoryNoMatchingSelector BundleConfigRemoteSyncErrorCategory = "NO_MATCHING_SELECTOR" ) // BundleConfigRemoteSyncEvent is emitted on every execution of the @@ -121,7 +122,9 @@ type BundleConfigRemoteSyncEvent struct { // stays in-region and is stripped from centralized logfood. Unset on success. ErrorMessage string `json:"error_message,omitempty"` - // Category of the failure when the command exits with an error. + // Category of the failure when the command exits with an error, or + // NO_MATCHING_SELECTOR when no selector matched (reported as skipped in JSON + // output). // Unset on success. ErrorCategory BundleConfigRemoteSyncErrorCategory `json:"error_category,omitempty"` }