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

Update forward_ssh_connectivity.private_key to be mutable #11930

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ari-hacks
Copy link

@ari-hacks ari-hacks commented Oct 4, 2024

This prevents the connection profile from failing permanently (needing to be re-created) when the forward ssh connectivity private key is updated.
Fixes hashicorp/terraform-provider-google#18999

Release Note Template for Downstream PRs (will be copied)

datastream: updated `private_key`to be mutable in `google_datastream_connection_profile` resource.

Copy link

google-cla bot commented Oct 4, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot requested a review from roaks3 October 4, 2024 23:30
Copy link

github-actions bot commented Oct 4, 2024

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@roaks3, 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 need reviewer's approval to run presubmit tests label Oct 4, 2024
Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

Code change looks fine, but the tests need a few tweaks. Mainly, we will want to be able to show in the PR checks that this behavior works.

@@ -72,6 +75,28 @@ func TestAccDatastreamConnectionProfile_update(t *testing.T) {
// Disable prevent_destroy
Config: testAccDatastreamConnectionProfile_mySQLUpdate(context, false, random_pass_2),
},
{
Config: testAccDatastreamConnectionProfile_SSHKey_Update(context, true, random_key_1),
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 a little strange, because destroy gets run after all steps are complete, and with the same instance name is being used, so I think it will try to update from mysql to postgres. I would create a new test if you need to use a postgres instance.

hostname = google_sql_database_instance.instance.public_ip_address
username = google_sql_user.user.name
port = 22
private_key = "%{private_key}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm no real familiar with the use case, but just in case it helps, this test only needs to do enough to use the private_key. If the other config here is extraneous, it could be removed to make things more focused, and possibly faster to deploy.

Copy link

@ari-hacks, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

Copy link

github-actions bot commented Nov 5, 2024

@ari-hacks, this PR is waiting for action from you. If no action is taken, this PR will be closed in 14 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

@github-actions github-actions bot requested a review from roaks3 November 12, 2024 13:57
Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

I can see you've been pretty thorough with your change, but the test still needs some work. I would really suggest creating a new test instead of adding to TestAccDatastreamConnectionProfile_update, but I think it could still technically work.

Here's what likely needs to change:

  • acctest.SkipIfVcr(t) would need to be removed so the test is run in the PR
  • RandSSHKeyPair() won't work because it will be random on every run (see mmv1/third_party/terraform/acctest/test_utils.go.tmpl), so you would need to wrap it. I would suggest just using RandString (or hard-coded keys) unless that causes issues for some reason.

Copy link

@ari-hacks, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

Copy link

@ari-hacks, this PR is waiting for action from you. If no action is taken, this PR will be closed in 14 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

@github-actions github-actions bot requested a review from roaks3 December 15, 2024 18:48
@ari-hacks
Copy link
Author

ari-hacks commented Dec 15, 2024

I can see you've been pretty thorough with your change, but the test still needs some work. I would really suggest creating a new test instead of adding to TestAccDatastreamConnectionProfile_update, but I think it could still technically work.

Here's what likely needs to change:

  • acctest.SkipIfVcr(t) would need to be removed so the test is run in the PR
  • RandSSHKeyPair() won't work because it will be random on every run (see mmv1/third_party/terraform/acctest/test_utils.go.tmpl), so you would need to wrap it. I would suggest just using RandString (or hard-coded keys) unless that causes issues for some reason.

Thanks @roaks3! Sorry for the delay on this.
Can you explain how this works a bit more, I'm not too familiar with go test/how it runs in the PR. I see all the test steps are wrapped in VcrTest. Does that means without SkipIfVcr(t) those test should run?

To get this working without too much of a lift what if we:

  • decouple this test from the other ones with your suggestion of creating a new test - I believe this would need a separate file? resource_datastream_connection_profile_frwd_ssh_test.go
  • RandString() doesn't support the key format for SSH so I can hard code a random private/public key pair

Copy link

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

@GoogleCloudPlatform/terraform-team @roaks3 This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

@GoogleCloudPlatform/terraform-team @roaks3 This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

github-actions bot commented Jan 6, 2025

@GoogleCloudPlatform/terraform-team @roaks3 This PR has been waiting for review for 3 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

I see all the test steps are wrapped in VcrTest. Does that means without SkipIfVcr(t) those test should run?

Yea, remove that line and the test will run in a PR check, which helps us ensure it passes before we merge.

decouple this test from the other ones with your suggestion of creating a new test - I believe this would need a separate file? resource_datastream_connection_profile_frwd_ssh_test.go

I would actually suggest using the existing file, but copying an existing testAcc... function, and then modifying as needed.

RandString() doesn't support the key format for SSH so I can hard code a random private/public key pair

Yep, hardcoding seems reasonable to me here.

Copy link

@ari-hacks, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-approval Pull requests that need reviewer's approval to run presubmit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating the private key in forward_ssh_connectivity causes a connection profile replacement
3 participants