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(spanner): add spanner sample snippet for creating asymmetric autoscaling instance #4845

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

Conversation

hibiken
Copy link

@hibiken hibiken commented Dec 11, 2024

Description

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Contributing Guidelines from CONTRIBUTING.MD
  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@hibiken hibiken requested review from a team as code owners December 11, 2024 20:51
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 11, 2024
Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi @hibiken and reviewers,

I'm currently reviewing this pull request and will post my detailed review in a few minutes. In the meantime, here's a quick summary to help everyone get up to speed:

This pull request adds a new Spanner sample snippet demonstrating how to create a Cloud Spanner instance with asymmetric autoscaling. The intent is to provide a clear example of configuring asymmetric autoscaling, allowing for independent scaling of read-only replicas across different regions. The changes include:

  • Addition of a new Go file: spanner/spanner_snippets/spanner/spanner_create_instance_with_asymmetric_autoscaling.go This file contains the code for creating a Spanner instance with asymmetric autoscaling configuration. The code creates an instance with a specified configuration, display name, autoscaling limits and targets, and importantly, asymmetric autoscaling options for read-only replicas in specific regions (europe-west1, europe-west4, and asia-east1).
  • Updates to go.mod and go.sum: These files are updated to reflect the addition of new dependencies required by the new sample snippet. Specifically, several indirect dependencies are added or updated to their latest versions.
  • Update to spanner/spanner_snippets/spanner/integration_test.go: The integration test file is updated to include a test case for the new createInstanceWithAsymmetricAutoscalingConfig function.

The overall effect is to expand the existing Spanner sample collection with a practical example of a more advanced configuration option.


And now, a little haiku to lighten the mood:

Cloud Spanner scales,
Regions rise and fall in sync,
Data flows so free.

@hibiken hibiken changed the title Add spanner sample snippet for creating asymmetric autoscaling instance feat(spanner): add spanner sample snippet for creating asymmetric autoscaling instance Dec 11, 2024
Copy link

conventional-commit-lint-gcf bot commented Dec 11, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

This pull request adds a new sample demonstrating how to create a Spanner instance with an asymmetric autoscaling configuration. The code is well-structured and easy to understand. The addition of this sample enhances the documentation and provides a valuable example for users interested in asymmetric autoscaling. The changes in go.mod and go.sum are appropriate and reflect the dependencies required for the new sample. The integration test covers the new sample function, ensuring its correctness. Overall, the pull request is well-done and ready for approval.

@@ -129,6 +129,7 @@ func TestCreateInstances(t *testing.T) {
runCreateAndUpdateInstanceSample(t, createInstanceWithoutDefaultBackupSchedule, updateInstanceDefaultBackupScheduleType)
runCreateInstanceSample(t, createInstanceWithProcessingUnits)
runCreateInstanceSample(t, createInstanceWithAutoscalingConfig)
runCreateInstanceSample(t, createInstanceWithAsymmetricAutoscalingConfig)

Choose a reason for hiding this comment

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

medium

It's a good practice to add a test case for the new sample function createInstanceWithAsymmetricAutoscalingConfig to ensure its correctness. Consider adding a test case similar to the existing ones, which checks the output of the function and verifies the instance creation.

Suggested change
runCreateInstanceSample(t, createInstanceWithAsymmetricAutoscalingConfig)
runCreateInstanceSample(t, createInstanceWithAsymmetricAutoscalingConfig)

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I would prefer to break out new tests into separate test cases whenever possible. Inline test executions like this are hard to debug and can cause merge conflicts when multiple authors are working on the same file. This change is not required, but strongly suggested.

See: https://googlecloudplatform.github.io/samples-style-guide/#dedicated-testing-per-sample

Copy link

snippet-bot bot commented Dec 11, 2024

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Dec 12, 2024
@telpirion telpirion self-assigned this Dec 12, 2024
…asymmetric_autoscaling.go

Co-authored-by: code-review-assist[bot] <182814678+code-review-assist[bot]@users.noreply.github.com>
Copy link
Collaborator

@telpirion telpirion left a comment

Choose a reason for hiding this comment

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

Only minor nits. Feel free to reject/accept as you see fit.

Thank you!

@@ -129,6 +129,7 @@ func TestCreateInstances(t *testing.T) {
runCreateAndUpdateInstanceSample(t, createInstanceWithoutDefaultBackupSchedule, updateInstanceDefaultBackupScheduleType)
runCreateInstanceSample(t, createInstanceWithProcessingUnits)
runCreateInstanceSample(t, createInstanceWithAutoscalingConfig)
runCreateInstanceSample(t, createInstanceWithAsymmetricAutoscalingConfig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I would prefer to break out new tests into separate test cases whenever possible. Inline test executions like this are hard to debug and can cause merge conflicts when multiple authors are working on the same file. This change is not required, but strongly suggested.

See: https://googlecloudplatform.github.io/samples-style-guide/#dedicated-testing-per-sample

"google.golang.org/genproto/protobuf/field_mask"
)

// Example of creating an asymmetric autoscaling enabled instance in Go.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: use typical Godoc styling where the first word of the comment is the same as the name of the function.

if err != nil {
return fmt.Errorf("waiting for instance creation to finish failed: %w", err)
}
// The instance may not be ready to serve yet.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the helpful comments in this sample!

@telpirion telpirion marked this pull request as draft December 12, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants