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

feat(cae/env): add new resource to manage environments #6134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lance52259
Copy link
Contributor

What this PR does / why we need it:
Add new resource support for the environments management.
The resource supports retry when the jobs failed (during create and delete function).

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. add new resource support for the environments management.
2. add related document and acceptance tests support.

PR Checklist

  • Tests added/passed.
./scripts/coverage.sh -o cae -f TestAccEnvironment_basic
Prepare to calculate the coverage the following command:
TF_ACC=1 go test "./huaweicloud/services/acceptance/cae" -v -coverprofile="./huaweicloud/services/acceptance/cae/cae_coverage.cov" -coverpkg="./huaweicloud/services/cae" -run TestAccEnvironment_basic -timeout 360m -parallel 10
=== RUN   TestAccEnvironment_basic
--- PASS: TestAccEnvironment_basic (507.31s)
PASS
coverage: 22.9% of statements in ./huaweicloud/services/cae
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/cae       507.378s        coverage: 22.9% of statements in ./huaweicloud/services/cae
  • Documentation updated.

  • Schema updated.

  • CheckDeleted.

    • a. During query operation (Read Context)
      aa. Resource not found
      image

    • b. During delete/disassociate/unbind operation (Delete Context)
      ba. Resource not found
      image

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

[APPROVALNOTIFIER] This PR is APPROVED

This PR has been approved by: @Lance52259

@github-ci-robot
Copy link
Collaborator

This PR needs rebase.

@Lance52259 Lance52259 force-pushed the br_cae_environment_active branch 2 times, most recently from f0d056a to 9613f5c Compare January 3, 2025 09:34
@Lance52259
Copy link
Contributor Author

./scripts/coverage.sh -o cae -f TestAccEnvironment_basic
Prepare to calculate the coverage the following command:
TF_ACC=1 go test "./huaweicloud/services/acceptance/cae" -v -coverprofile="./huaweicloud/services/acceptance/cae/cae_coverage.cov" -coverpkg="./huaweicloud/services/cae" -run TestAccEnvironment_basic -timeout 360m -parallel 10
=== RUN   TestAccEnvironment_basic
--- PASS: TestAccEnvironment_basic (429.21s)
PASS
coverage: 23.1% of statements in ./huaweicloud/services/cae
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/cae       429.261s        coverage: 23.1% of statements in ./huaweicloud/services/cae

@Lance52259 Lance52259 force-pushed the br_cae_environment_active branch 2 times, most recently from 9285114 to 2700823 Compare January 6, 2025 08:09
@Lance52259
Copy link
Contributor Author

./scripts/coverage.sh -o cae -f TestAccEnvironment_basic
Prepare to calculate the coverage the following command:
TF_ACC=1 go test "./huaweicloud/services/acceptance/cae" -v -coverprofile="./huaweicloud/services/acceptance/cae/cae_coverage.cov" -coverpkg="./huaweicloud/services/cae" -run TestAccEnvironment_basic -timeout 360m -parallel 10
=== RUN   TestAccEnvironment_basic
--- PASS: TestAccEnvironment_basic (430.88s)
PASS
coverage: 20.2% of statements in ./huaweicloud/services/cae
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/cae       430.964s        coverage: 20.2% of statements in ./huaweicloud/services/cae

@Lance52259 Lance52259 force-pushed the br_cae_environment_active branch 2 times, most recently from 71c616f to ffd19dc Compare January 9, 2025 01:57
@Lance52259 Lance52259 force-pushed the br_cae_environment_active branch from ffd19dc to edcae14 Compare January 9, 2025 07:18

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add timeouts descriptions in documentation.

}
createResp, err := client.Request("GET", getPath, &getOpts)
if err != nil {
return nil, fmt.Errorf("error query job by its ID (%s): %s", jobId, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error query job by its ID (%s): %s", jobId, err)
return nil, fmt.Errorf("error querying job by its ID (%s): %s", jobId, err)

return diag.Errorf("unable to find the job ID from the API response")
}
err = waitForEnvironmentJobComplete(ctx, client, epsId, jobId, d.Timeout(schema.TimeoutDelete), d.Get("max_retries").(int))
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if err != nil {
return diag.FromErr(err)

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. feature size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants