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(vertexai): Support google_vertex_ai_deployment_resource_pool #9518

Conversation

shotarok
Copy link
Contributor

@shotarok shotarok commented Nov 24, 2023

Fixes hashicorp/terraform-provider-google#16561

Release Note Template for Downstream PRs (will be copied)

`google_vertex_ai_deployment_resource_pool`

I confirmed TestAccVertexAIDeploymentResourcePool_vertexAiDeploymentResourcePoolExample succeeded without errors by running the test on a local machine.

@modular-magician
Copy link
Collaborator

Hello! I am a robot. It looks like you are a: Community Contributor Googler Core Contributor. Tests will require approval to run.

@rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Nov 24, 2023
Comment on lines 51 to 52
# Skip the import test because deployment_resource_pool_id can't be specified in an auto-generated test
skip_import_test: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[QUESTION] Should I add a manually written test for importing a resource by specifying ImportId:?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, the import format we're creating is wrong- it assumes that /{{name}} is appended to the base_url. If we add an identity entry similar to

, this should generate import formats that are correct & compatible with the resource id (which is used as the import key)

For this resource that value'll be deploymentResourcePoolId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment! I updated the code to use name as identifier along with the custom encoder in 99bb911. So skip_import_test and identity became unnecessary in the end.

mmv1/products/vertexai/DeploymentResourcePool.yaml Outdated Show resolved Hide resolved
Comment on lines 72 to 73
# Deal with deploymentResourcePool as a flatten object because GET returns DeploymentResourcePool
flatten_object: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Instead of flatten_object can we use an encoder? Very similar to something like https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/templates/terraform/encoders/wrap_object_with_template_id.go.erb

(We likely need to remove deploymentResourcePoolId from obj and reinsert it to obj, I think that that encoder's resourceId field was url_param_only)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback. I updated the code to use the custom encoder in 99bb911.

@shotarok
Copy link
Contributor Author

@rileykarson Hello 👋 Could you approve the cloud build jobs to run acceptance tests?

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Nov 28, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 5 files changed, 1146 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1146 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 239 insertions(+))
TF OiCS: Diff ( 4 files changed, 120 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3238
Passed tests 2905
Skipped tests: 331
Affected tests: 2

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccHealthcareDatasetIamPolicy|TestAccVertexAIDeploymentResourcePool_vertexAiDeploymentResourcePoolExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccHealthcareDatasetIamPolicy[Debug log]
TestAccVertexAIDeploymentResourcePool_vertexAiDeploymentResourcePoolExample[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

Comment on lines 51 to 52
# Skip the import test because deployment_resource_pool_id can't be specified in an auto-generated test
skip_import_test: true
Copy link
Member

Choose a reason for hiding this comment

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

Ah, the import format we're creating is wrong- it assumes that /{{name}} is appended to the base_url. If we add an identity entry similar to

, this should generate import formats that are correct & compatible with the resource id (which is used as the import key)

For this resource that value'll be deploymentResourcePoolId

Comment on lines 72 to 73
# Deal with deploymentResourcePool as a flatten object because GET returns DeploymentResourcePool
flatten_object: true
Copy link
Member

Choose a reason for hiding this comment

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

Instead of flatten_object can we use an encoder? Very similar to something like https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/templates/terraform/encoders/wrap_object_with_template_id.go.erb

(We likely need to remove deploymentResourcePoolId from obj and reinsert it to obj, I think that that encoder's resourceId field was url_param_only)

mmv1/products/vertexai/DeploymentResourcePool.yaml Outdated Show resolved Hide resolved
mmv1/products/vertexai/DeploymentResourcePool.yaml Outdated Show resolved Hide resolved
@@ -0,0 +1,19 @@
resource "google_vertex_ai_deployment_resource_pool" "<%= ctx[:primary_resource_id] %>" {
region = "us-central1"
deployment_resource_pool_id = "sample-deployment-resource-pool"
Copy link
Member

Choose a reason for hiding this comment

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

We'll want to define vars and supply the name through that- that will ensure that we add a random suffix and a sweeper prefix to test resources so that we don't leak resources or fail tests due to leaked resources.

Docs: https://googlecloudplatform.github.io/magic-modules/develop/test/#add-a-create-test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the code to use the random suffix through vars in 99bb911.

@modular-magician modular-magician added the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Dec 12, 2023
@shotarok
Copy link
Contributor Author

@rileykarson Hello 👋 Sorry for the late response. I updated the code based on your feedback. According to the API doc, all fields are immutable. Therefore, I didn't add a hand-written test for updatable fields. Please let me know if you have a concern. Thanks!

@shotarok
Copy link
Contributor Author

shotarok commented Jan 2, 2024

@rileykarson Happy New Year 👋 When you have time, could you review this PR? Thanks

@shotarok
Copy link
Contributor Author

@rileykarson Hello 👋 When you have time, could you review this PR? Thanks!

@shotarok
Copy link
Contributor Author

@rileykarson Hello 👋 If this PR looks good, could you approve the cloud build job? Thanks

@rileykarson
Copy link
Member

Sorry about the delay! Losing against my email 😅

Running build

@modular-magician modular-magician removed the awaiting-approval Pull requests that needs reviewer's approval to run presubmit tests label Feb 16, 2024
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 5 files changed, 1106 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1106 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 215 insertions(+))
TF OiCS: Diff ( 4 files changed, 120 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 46
Passed tests 45
Skipped tests: 0
Affected tests: 1

Click here to see the affected service packages
  • vertexai

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccVertexAIDeploymentResourcePool_vertexAiDeploymentResourcePoolExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccVertexAIDeploymentResourcePool_vertexAiDeploymentResourcePoolExample[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@shotarok
Copy link
Contributor Author

@rileykarson Hello 👋 When you have time, could you review the code? Please let me know if merging the latest main branch into this development branch is necessary. Thanks!

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

LGTM, sorry for the delay!

@rileykarson rileykarson merged commit 83d97a1 into GoogleCloudPlatform:main Mar 27, 2024
14 checks passed
cmfeng pushed a commit to cmfeng/cmfeng-magic-modules that referenced this pull request Apr 5, 2024
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support the new resource: google_vertex_ai_deployment_resource_pool
3 participants