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

Support Self Service Maintenance feature #6131

Merged
merged 36 commits into from
Sep 27, 2022

Conversation

2tricpony
Copy link
Contributor

@2tricpony 2tricpony commented Jun 14, 2022

Support Self Service Maintenance feature. This adds support for 2 API fields - maintenance_version and available_maintenance_version. Fixes hashicorp/terraform-provider-google#11881

maintenance_version feature summary:

  • can't be set during creation (API will return error if it's set during creation)
  • can only be set to versions in available_maintenance_version
  • versions set to an older one than the current one will be ignored
  • versions set to invalid newer versions will run into API errors

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • [] Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

sql: added `maintenance_version` and `available_maintenance_versions` fields to `google_sql_database_instance` resource

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • sql: added maintenance_version and 'available_maintenance_versions' fields in google_sql_database_instance

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @shuyama1, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 42 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 2 files changed, 42 insertions(+), 3 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2052
Passed tests 1823
Skipped tests: 226
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests TestAccContainerCluster_withConfidentialNodes|TestAccContainerCluster_withAddons|TestAccSqlUser_mysqlDisabled

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccSqlUser_mysqlDisabled[view]

Tests failed during RECORDING mode:
TestAccContainerCluster_withAddons[view]
TestAccContainerCluster_withConfidentialNodes[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@shuyama1
Copy link
Member

Question: Is available_maintenance_versions an output-only field while maintenance_version is not?
Just want to make sure if I understand correctly. Many thanks!

@2tricpony
Copy link
Contributor Author

That is correct! availabe_maintenance_versions can never be updated. maintenance_version field can be updated to any of versions specified in the available_maintenance_versions field.

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Would you mind adding a test or modifying an existing test for these two added fields?

@@ -68,6 +68,22 @@ objects:
- :FIRST_GEN
- :SECOND_GEN
- :EXTERNAL
- !ruby/object:Api::Type::String
name: 'maintenanceVersion'
output: true
Copy link
Member

Choose a reason for hiding this comment

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

Sounds like maintenanceVersion is not an output-only field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. It can be updated after instance creation.

"available_maintenance_versions": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Copy link
Member

Choose a reason for hiding this comment

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

If this is an output-only field, we probably want to remove Optional: 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.

Done.

@shuyama1 shuyama1 removed their request for review July 15, 2022 04:26
@shuyama1 shuyama1 removed their request for review July 15, 2022 05:03
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 75 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 3 files changed, 75 insertions(+), 3 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2112
Passed tests 1879
Skipped tests: 226
Failed tests: 7

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests TestAccFirebaserulesRelease_BasicRelease|TestAccComputeInstance_soleTenantNodeAffinities|TestAccPrivatecaCertificateAuthority_subordinateCaActivatedByFirstPartyIssuerOnCreation|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccSqlDatabaseInstance_maintenanceVersionWithOldVersion_suppressConfig|TestAccSqlDatabaseInstance_basicMSSQL|TestAccSqlDatabaseInstance_SqlServerAuditConfig

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccSqlDatabaseInstance_basicMSSQL[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]
TestAccSqlDatabaseInstance_maintenanceVersionWithOldVersion_suppressConfig[view]
TestAccFirebaserulesRelease_BasicRelease[view]

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccPrivatecaCertificateAuthority_subordinateCaActivatedByFirstPartyIssuerOnCreation[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@2tricpony
Copy link
Contributor Author

Hi shuyama1,

I have addressed the changes that were requested. Please take another look.

@shuyama1
Copy link
Member

@2tricpony Thanks for making the update! Sorry for the delay. I'll start reviewing the PR.

@2tricpony
Copy link
Contributor Author

Gentle ping on this. :)

@shuyama1
Copy link
Member

shuyama1 commented Aug 9, 2022

@2tricpony Sorry, this fell off my radar. Thanks for the ping!

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Based on the debug log, it seems that the maintenance_version is not included in the request body even if we config it explicitly. Should it throw error if we set this field in the creation step (as we discussed offline)?
Also would you mind adding an update step for this feature? I understand that the it can not really update the resource(as the newly created instance should have the most recent version if I understand correctly), but we can just add it to check if it can be sent correctly via the API call. Many thanks! Let me know if you got any questions.

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[Error message] [Debug log]
TestAccCGCSnippet_eventarcWorkflowsExample[Error message] [Debug log]
TestAccSqlDatabaseInstance_maintenanceVersion[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

Comment on lines +403 to +412
resource.TestStep{
Config: fmt.Sprintf(
testGoogleSqlDatabaseInstance_maintenanceVersionWithOldVersion, databaseName),
},
resource.TestStep{
ResourceName: "google_sql_database_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
Copy link
Member

@shuyama1 shuyama1 Sep 20, 2022

Choose a reason for hiding this comment

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

I believe this is a copy error and should be removed?

@2tricpony
Copy link
Contributor Author

Added the suppressDiffFunc back.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2177
Passed tests 1936
Skipped tests: 238
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccComputeInstance_soleTenantNodeAffinities|TestAccCGCSnippet_eventarcWorkflowsExample

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[Error message] [Debug log]
TestAccCGCSnippet_eventarcWorkflowsExample[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@@ -1428,6 +1477,16 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
return resourceSqlDatabaseInstanceRead(d, meta)
}

func maintenanceVersionDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
// Ignore the database version part and only compare the last part of the maintenance version which represents the release date of the version.
if len(old) > 14 && len(new) > 14 && old[len(old)-14:] > new[len(new)-14:] {
Copy link
Member

Choose a reason for hiding this comment

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

Question: Do you think if we should suppress when old[len(old)-14:] = new[len(new)-14:]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. If the version is same, it's a no-op on the backend. Having said that, I think we can also suppress on Terraform side when it's equal. I have added that logic.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2182
Passed tests 1942
Skipped tests: 238
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccComputeInstance_soleTenantNodeAffinities|TestAccCGCSnippet_eventarcWorkflowsExample

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[Error message] [Debug log]
TestAccCGCSnippet_eventarcWorkflowsExample[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Tested it locally and LGTM in general! Just some nitpicks on documentation. Also please rebase the PR if conflicts occur. Thank you!

@2tricpony
Copy link
Contributor Author

Thank you for verifying! I have updated the PR and I didn't find any conflicts.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 3 files changed, 150 insertions(+), 2 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2182
Passed tests 1926
Skipped tests: 238
Failed tests: 18

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccComputeServiceAttachment_serviceAttachmentBasicExample|TestAccComputeVpnTunnel_regionFromGateway|TestAccComputePacketMirroring_computePacketMirroringFullExample|TestAccComputeRoute_routeIlbVipExample|TestAccComputeRoute_routeIlbExample|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccComputeGlobalForwardingRule_labels|TestAccComputeGlobalForwardingRule_ipv6|TestAccComputeGlobalForwardingRule_updateTarget|TestAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample|TestAccComputeGlobalForwardingRule_globalForwardingRuleHybridExample|TestAccComputeGlobalForwardingRule_globalForwardingRuleInternalExample|TestAccComputeForwardingRule_serviceDirectoryRegistrations|TestAccComputeForwardingRule_update|TestAccCGCSnippet_eventarcWorkflowsExample|TestAccComputeForwardingRule_internalHttpLbWithMigBackendExample

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]
TestAccComputeServiceAttachment_serviceAttachmentBasicExample[Debug log]
TestAccComputeVpnTunnel_regionFromGateway[Debug log]
TestAccComputePacketMirroring_computePacketMirroringFullExample[Debug log]
TestAccComputeRoute_routeIlbVipExample[Debug log]
TestAccComputeRoute_routeIlbExample[Debug log]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[Debug log]
TestAccComputeGlobalForwardingRule_labels[Debug log]
TestAccComputeGlobalForwardingRule_ipv6[Debug log]
TestAccComputeGlobalForwardingRule_updateTarget[Debug log]
TestAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample[Debug log]
TestAccComputeGlobalForwardingRule_globalForwardingRuleHybridExample[Debug log]
TestAccComputeGlobalForwardingRule_globalForwardingRuleInternalExample[Debug log]
TestAccComputeForwardingRule_serviceDirectoryRegistrations[Debug log]
TestAccComputeForwardingRule_update[Debug log]
TestAccComputeForwardingRule_internalHttpLbWithMigBackendExample[Debug log]

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[Error message] [Debug log]
TestAccCGCSnippet_eventarcWorkflowsExample[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

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.

Add support for maintenance_version and available_maintenance_versions field
3 participants