Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed auto-purged cluster behaviour for databricks_library #1745

Merged
merged 7 commits into from
Nov 10, 2022

Conversation

yugireddy-db
Copy link
Contributor

@yugireddy-db yugireddy-db commented Nov 9, 2022

Changes to libraries module to address the Issue #1737

The changes enable:

  1. Move forward with the resource creation on available clusters when the library installation error occurs on the non-existent cluster, previously the flow used to stop and failed with Error: cannot read library: Cluster 1234-123456-u2ab23hh does not exist

@@ -83,7 +83,7 @@ func (a LibrariesAPI) WaitForLibrariesInstalled(wait Wait) (result *ClusterLibra
return resource.RetryableError(err)
}
if err != nil {
return resource.NonRetryableError(err)
return resource.NonRetryableError(wrapClusterStatusAPIError(err, wait.ClusterID))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, so please simplify the logic here between lines 81 and 87. the new logic should be something like: if we get error from a.ClusterStatus, return it as non-retriable.

you probably need to directly paste only these lines:

        apiErr, ok := err.(common.APIError)
	if !ok {
		return resource.NonRetryableError(err)
	}
	// fix non-compliant error code
	if apiErr.StatusCode != 404 && strings.Contains(apiErr.Message, 
                fmt.Sprintf("Cluster %s does not exist", id)) {
		apiErr.StatusCode = 404
	}
        return resource.NonRetryableError(apiErr)

then amount of unit tests will be smaller ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nfx Updated per your suggestion, please review and confirm if we are good.

_, err = libs.WaitForLibrariesInstalled(Wait{
"1005-abcd", 50 * time.Millisecond, false, false,
})
assert.EqualError(t, err, "Cluster 1005-abcd does not exist")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also check for 404 StatusCode of APIError here? this is the condition that triggers resource deletion.

@nfx nfx marked this pull request as ready for review November 9, 2022 22:58
@nfx nfx changed the title Changes to libraries module to address the Issue#1737 Fixed auto-purged cluster behaviour for databricks_library Nov 9, 2022
@nfx nfx merged commit 87e590d into databricks:master Nov 10, 2022
@yugireddy-db yugireddy-db deleted the Issue_1737 branch November 10, 2022 13:32
@nfx nfx mentioned this pull request Nov 11, 2022
michael-berk pushed a commit to michael-berk/terraform-provider-databricks that referenced this pull request Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants