Skip to content

Fix recreating a deleted cluster when the library-status lookup responds first - #7647

Open
pcbeingused333 wants to merge 2 commits into
databricks:mainfrom
pcbeingused333:fix/7565-deleted-cluster-library-race
Open

pcbeingused333 wants to merge 2 commits into
databricks:mainfrom
pcbeingused333:fix/7565-deleted-cluster-library-race

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #7565

Changes

bundle plan and bundle deploy recreate a cluster that was deleted outside the bundle even when the libraries status lookup responds before the cluster lookup.

Why

ResourceCluster.DoRead reads the cluster and its libraries together and used to return whichever error finished first. The libraries API reports a missing cluster as 400 INVALID_PARAMETER_VALUE. The planner only treats apierr.IsMissing as gone, and that code is not missing: the SDK remaps it only for GET /clusters/get. Planning aborted whenever the libraries lookup won the race. A failed cluster read, including not-found, now decides the outcome. A library error is still returned when the cluster itself was read, so a real library failure on a live cluster is unchanged.

Tests

TestClusterDoReadDeletedClusterIgnoresLibraryStatusOrder forces each lookup to finish first. On main, the libraries-first case returns INVALID_PARAMETER_VALUE and is not a missing-resource error. With this change both orders return the cluster not-found error. TestClusterDoReadLibraryErrorSurfacesWhenClusterExists still returns a library-status error for a live cluster, and TestClusterDoReadReturnsInstalledLibraries still keeps installed libraries and skips libraries installed for all clusters.

This change was prepared with the help of an AI coding assistant.

DoRead ran the cluster and library-status lookups together and returned
the first error. library-status reports a deleted cluster as
INVALID_PARAMETER_VALUE, which the planner does not treat as missing, so
plan and deploy aborted whenever that lookup finished first.

Return the cluster error whenever the cluster read fails, and return a
library error only after the cluster itself was read.

Fixes databricks#7565
@pcbeingused333
pcbeingused333 requested review from a team as code owners November 16, 2026 01:06
@pcbeingused333
pcbeingused333 requested a review from denik November 16, 2026 01:06
@github-actions github-actions Bot added the DABs DABs related issues label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution! This pull request was opened from a fork.

If you're a member of the Databricks organization, please request access to the cli-contrib team and open your pull request from a branch in this repository instead of a fork — fork PRs don't run integration tests automatically and have reduced CI access.

If you're an external contributor, no action is needed; a maintainer will review your pull request.

@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 7647
  • Commit SHA: ad66a91b2c872b0e730d4c593b640e60f806cbfe

Checks will be approved automatically on success.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct engine intermittently fails to recreate deleted clusters when library-status lookup wins race

1 participant