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

apply debug_truncate_bytes also for response dumps #589

Merged
merged 1 commit into from
Apr 9, 2021
Merged
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
6 changes: 5 additions & 1 deletion common/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@ func (c *DatabricksClient) redactedDump(body []byte) (res string) {
// error in this case is not much relevant
return
}
return onlyNBytes(string(rePacked), 1024)
maxBytes := 1024
if c.DebugTruncateBytes > maxBytes {
maxBytes = c.DebugTruncateBytes
}
return onlyNBytes(string(rePacked), maxBytes)
}

func (c *DatabricksClient) userAgent(ctx context.Context) string {
Expand Down
9 changes: 5 additions & 4 deletions compute/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,15 @@ func (a ClustersAPI) waitForClusterStatus(clusterID string, desired ClusterState
}
if !clusterInfo.State.CanReach(desired) {
docLink := "https://docs.databricks.com/dev-tools/api/latest/clusters.html#clusterclusterstate"
details := ""
if clusterInfo.TerminationReason != nil {
log.Printf("[DEBUG] Cluster %s termination info: code: %s, type: %s, parameters: %v",
clusterID, clusterInfo.TerminationReason.Code, clusterInfo.TerminationReason.Type,
details = fmt.Sprintf(", Termination info: code: %s, type: %s, parameters: %v",
clusterInfo.TerminationReason.Code, clusterInfo.TerminationReason.Type,
clusterInfo.TerminationReason.Parameters)
}
return resource.NonRetryableError(fmt.Errorf(
"%s is not able to transition from %s to %s: %s. Please see %s for more details",
clusterID, clusterInfo.State, desired, clusterInfo.StateMessage, docLink))
"%s is not able to transition from %s to %s: %s%s. Please see %s for more details",
clusterID, clusterInfo.State, desired, clusterInfo.StateMessage, details, docLink))
Copy link
Contributor

Choose a reason for hiding this comment

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

this is much better to have it part of a propagated error! :)

}
return resource.RetryableError(
fmt.Errorf("%s is %s, but has to be %s",
Expand Down
3 changes: 2 additions & 1 deletion compute/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ func TestWaitForClusterStatus_NotReachable(t *testing.T) {
ctx := context.Background()
_, err = NewClustersAPI(ctx, client).waitForClusterStatus("abc", ClusterStateRunning)
require.Error(t, err)
assert.Contains(t, err.Error(), "abc is not able to transition from UNKNOWN to RUNNING: Something strange is going on.")
assert.Contains(t, err.Error(), "abc is not able to transition from UNKNOWN to RUNNING: Something strange is going on")
assert.Contains(t, err.Error(), "code: unknown, type: broken")
}

func TestWaitForClusterStatus_NormalRetry(t *testing.T) {
Expand Down