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

fix(dli): catch and handle the 408 errors #4706

Merged
merged 1 commit into from
May 16, 2024

Conversation

Lance52259
Copy link
Collaborator

What this PR does / why we need it:

When resource (database or data table) create or delete by provider, due to the shared queue is their bottom layer relies resource, timeout errors (status code: 408, error code: DLI.0019) will be frequently returned when the usage is large.

{
 "error_code": "DLI.0019",
 "error_msg": "Get sync job result timeout with id: 5e913d04-4c23-48ea-a71f-3f6c678e7bd7"
}

If you try again immediately, the following error will be thrown:

{
 "error_code": "DLI.0005",
 "error_msg": "AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: AlreadyExistsException(message:Table tf_test_db9z6 already exists);\\nCause by: HiveException: AlreadyExistsException(message:Table tf_test_db9z6 already exists)\\nCause by: AlreadyExistsException: Table tf_test_db9z6 already exists"
}

Which issue this PR fixes:
(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)
fixes #xxx

Special notes for your reviewer:

Release note:

1. catch and handle the 408 errors

PR Checklist

  • Tests added/passed.
  • Documentation updated.
  • Schema updated.

Acceptance Steps Performed

make testacc TEST='./huaweicloud/services/acceptance/dli' TESTARGS='-run=TestAccResourceDliTable_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud/services/acceptance/dli -v -run=TestAccResourceDliTable_basic -timeout 360m -parallel 4
=== RUN   TestAccResourceDliTable_basic
=== PAUSE TestAccResourceDliTable_basic
=== CONT  TestAccResourceDliTable_basic
--- PASS: TestAccResourceDliTable_basic (37.46s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/dli       37.509s

@github-ci-robot github-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 26, 2024
@github-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This PR has been approved by: @Lance52259

return diag.Errorf("error creating DLI database (%s): %s", dbName, err)
}
} else if resp != nil && !resp.IsSuccess {
return diag.Errorf("the request was sent successfully, but some errors occurred: %s", resp.Message)
Copy link
Contributor

@deer-hang deer-hang May 16, 2024

Choose a reason for hiding this comment

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

if resp == nil {
  return diag.Errorf("error creating DLI database (%s): The creation API response is empty.", dbName)
}

if !resp.IsSuccess {
  return diag.Errorf("the request was sent successfully, but some errors occurred: %s", resp.Message)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't care about the case of the response is nil, because we don't need to parse it.

if err != nil {
return diag.Errorf("error create DLI datatable (%s) to the database (%s): %s", databaseName, tableName, err)
}
} else if resp != nil && !resp.IsSuccess {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

if _, ok := queryErr.(golangsdk.ErrDefault404); !ok {
return detail, "ERROR", queryErr
}
return detail, "COMPLETED", nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Variable detail may be nil.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the result of Get() method during golangsdk will have the type value (corresponding structure) in any times, will not be nil (nil means the type and value are both empty)

@deer-hang
Copy link
Contributor

Please add descriptions of timeout in the document dli_database.md and dli_table.md.

@deer-hang
Copy link
Contributor

/lgtm

@github-ci-robot github-ci-robot added the LGTM /lgtm label May 16, 2024
@github-ci-robot github-ci-robot merged commit f7775ec into huaweicloud:master May 16, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugfix LGTM /lgtm size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants