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(storage): add gRPC quickstart sample #4438

Merged
merged 19 commits into from
Oct 22, 2024
Merged

feat(storage): add gRPC quickstart sample #4438

merged 19 commits into from
Oct 22, 2024

Conversation

frankyn
Copy link
Member

@frankyn frankyn commented Oct 15, 2024

Description

Fixes b/373643411

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

Checklist

  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Oct 15, 2024
@frankyn frankyn marked this pull request as ready for review October 15, 2024 17:27
@frankyn frankyn requested review from a team as code owners October 15, 2024 17:27
Copy link

snippet-bot bot commented Oct 15, 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

@telpirion telpirion self-assigned this Oct 15, 2024
Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

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

Few minor comments, otherwise lgtm


stdOut, stdErr, err := m.Run(nil, time.Minute, "--project", tc.ProjectID, "--bucket", bucketName)

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.

Should we also specifically check for the error about directPath not being enabled or metrics not being enabled? Do we want to try to ensure that these things work properly for the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Warning wasn't implemented into the new auth code path introduced in recent releases and didn't see that until now. filed issue: googleapis/google-cloud-go#11001

Copy link
Contributor

Choose a reason for hiding this comment

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

My point was that we probably don't want to be getting these warnings, right? We want to quickstart to be able to run without warnings if the project has the correct permissions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Failed to enable client metrics isn't logged with existing tests. However, current implementation is emitting a warning that the Resource Detector detected a different project compared to the project used by the Go client. Can talk through this with you when you're back on.

)

const (
testPrefix = "test-gcs-grpc-team"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need an allowlisted prefix now that this is GA? Let's just say storage-grpc-quickstart-test maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it's still required; fails otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm when is the allowlist dropped?

Let's use the same prefix we use in the storage client integration tests ("golang-grpc-test").

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated as it's not longer required.

defer client.Close()

// Creates a Bucket instance.
bucket := client.Bucket(*bucketName)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be a separate line of code and comment; can just do client.Bucket(*bucketName).Create() on L52 instead.

@tritone tritone assigned tritone and unassigned telpirion Oct 16, 2024
@danielduhh danielduhh added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2024
@tritone tritone added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2024
@frankyn frankyn added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 18, 2024
@telpirion telpirion self-assigned this Oct 22, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: let's move this sample to the storage_quickstart folder. I think it makes more sense to have these two quickstarts side-by-side.

FWIW, it looks like the Java and C++ versions of this sample are in the same folders & packages as the HTTP version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Package names need to match if stored in the same directory which means we can't use main() for both. I need to put it into a different directory at least in Golang.

https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MismatchedPkgName

Moving into separate directory to unblock PR.

ctx := context.Background()

// Expects Google Cloud Platform project ID and Cloud Storage bucket
projectID := flag.String("project", "", "Cloud Platform project id")
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue: current best practice for samples is to forego a CLI.

See the Sample Style Guide:
https://googlecloudplatform.github.io/samples-style-guide/#no-cli

In the case of Go quickstarts, we've typically just not included tests (not great, I know) so as to have a "main" method.

@@ -0,0 +1,67 @@
// Copyright 2024 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

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

See previous comment about testing quickstarts.

@frankyn frankyn removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 22, 2024
@frankyn frankyn enabled auto-merge (squash) October 22, 2024 22:18
@frankyn frankyn merged commit 73ef014 into main Oct 22, 2024
10 checks passed
@frankyn frankyn deleted the add_grpc_quickstart branch October 22, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants