Skip to content

clusters start: make the command idempotent when cluster is already active#5776

Open
sridhar-3009 wants to merge 1 commit into
databricks:mainfrom
sridhar-3009:fix/clusters-start-idempotent-1372
Open

clusters start: make the command idempotent when cluster is already active#5776
sridhar-3009 wants to merge 1 commit into
databricks:mainfrom
sridhar-3009:fix/clusters-start-idempotent-1372

Conversation

@sridhar-3009

Copy link
Copy Markdown

Problem

databricks clusters start <cluster-id> fails with an error when the cluster is already running:

Error: INVALID_STATE: Cluster <id> is in unexpected state Running

The Databricks documentation states:

If the cluster is not currently in a TERMINATED state, nothing will happen.

The CLI was propagating the API's INVALID_STATE response as a hard error instead of treating it as a no-op.

Fix

Added a startIdempotentOverride in cmd/workspace/clusters/start_idempotent.go that wraps the generated command's RunE. Before calling the API, it fetches the current cluster state. If the cluster is already in any non-TERMINATED state (RUNNING, RESIZING, PENDING, etc.), it logs a message and returns nil, matching the documented behavior.

The original RunE is still called for TERMINATED clusters and for cases where no cluster ID is available before the picker runs.

Tests

Added unit tests covering:

  • RUNNING cluster → no-op, no error
  • RESIZING cluster → no-op, no error
  • TERMINATED cluster → proceeds to call start normally
  • PENDING cluster → no-op, no error

Fixes #1372

…ctive

The Databricks API rejects a start request with INVALID_STATE when the
cluster is not in TERMINATED state, but the documentation says "If the
cluster is not currently in a TERMINATED state, nothing will happen."

Before this change, running `databricks clusters start <id>` on an
already-running cluster produced an error. After this change the command
checks the cluster state first and exits with a log message if the cluster
is already active (RUNNING, RESIZING, PENDING, etc.), matching the
documented behavior.

Fixes databricks#1372
@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: 5776
  • Commit SHA: 4118fc4326b1e63b63bfe7cc9505778bee5311c5

Checks will be approved automatically on success.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @pietern -- recent work in cmd/workspace/clusters/

Eligible reviewers: @andrewnester, @anton-107, @denik, @renaudhartert-db, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

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

Labels

None yet

1 participant