Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mws/resource_mws_workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ func (a WorkspacesAPI) WaitForExpectedStatus(ws Workspace, expectedStatus string
return resource.NonRetryableError(err)
}

// If expected status is PROVISIONING but workspace is already RUNNING,
// consider it successful since RUNNING is a more advanced state
if expectedStatus == WorkspaceStatusProvisioning && workspace.WorkspaceStatus == WorkspaceStatusRunning {
log.Printf("[INFO] Workspace is RUNNING, which is acceptable when expected status is PROVISIONING")
return nil
}

switch workspace.WorkspaceStatus {
case expectedStatus:
log.Printf("[INFO] Workspace is now in expected status %s", expectedStatus)
Expand Down
25 changes: 25 additions & 0 deletions mws/resource_mws_workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,31 @@ func TestWorkspace_WaitForResolve(t *testing.T) {
})
}

func TestWorkspace_WaitForProvisioningWhenRunning(t *testing.T) {
// Test that when expected status is PROVISIONING but workspace is already RUNNING,
// it should be accepted as successful (RUNNING is a more advanced state)
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.0/accounts/abc/workspaces/1234",
ReuseRequest: true,
Response: Workspace{
AccountID: "abc",
WorkspaceID: 1234,
WorkspaceStatus: WorkspaceStatusRunning,
DeploymentName: "test-workspace",
},
},
}, func(ctx context.Context, client *common.DatabricksClient) {
a := NewWorkspacesAPI(ctx, client)
err := a.WaitForExpectedStatus(Workspace{
AccountID: "abc",
WorkspaceID: 1234,
}, WorkspaceStatusProvisioning, 1*time.Second)
assert.NoError(t, err, "Should accept RUNNING state when expected status is PROVISIONING")
})
}

func updateWorkspaceScimFixture(t *testing.T, fixtures []qa.HTTPFixture, state map[string]string, hcl string) {
accountsAPI := []qa.HTTPFixture{
{
Expand Down
Loading