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

Replace pborman/uuid with google/uuid #550

Merged
merged 2 commits into from
Apr 25, 2024
Merged

Replace pborman/uuid with google/uuid #550

merged 2 commits into from
Apr 25, 2024

Conversation

danw
Copy link
Contributor

@danw danw commented Apr 12, 2024

The two functions we were using were just thin wrappers around google/uuid anyways:

  • New() -> NewRandom(), then .String()
  • Parse(...) returns an error instead of a nil result

NewRandom() returns an error instead of an invalid UUID, so handle that as appropriate (we weren't really handling it appropriately in the current upload paths)

@@ -1069,9 +1069,9 @@ func (u *uploader) streamFromReader(ctx context.Context, r io.Reader, digest *re
instanceSegment = ""
}
if compressed {
req.ResourceName = fmt.Sprintf("%suploads/%s/compressed-blobs/zstd/%s/%d", instanceSegment, uuid.New(), digest.Hash, digest.SizeBytes)
req.ResourceName = fmt.Sprintf("%suploads/%s/compressed-blobs/zstd/%s/%d", instanceSegment, uuid.New().String(), digest.Hash, digest.SizeBytes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

New() and NewString() may panic. Perhaps a convenient function to log the error and gracefully return an empty string would better match the current behaviour.

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 didn't end up making a convenience wrapper, since I converted a few of these over to actual error handling instead. An empty string here would/could have caused different failures later on. In the actual optional cases I did add logging.

@mrahs
Copy link
Collaborator

mrahs commented Apr 25, 2024

Looks like there is simple merge conflict in build files.

The two functions we were using were just thin wrappers around
google/uuid anyways:

* `New()` -> `New().String()`
* `Parse(...)` returns an `error` instead of a `nil` result
When we need a UUID to upload, return an error. Otherwise, log the error
and continue with an empty string.
@danw
Copy link
Contributor Author

danw commented Apr 25, 2024

Looks like there is simple merge conflict in build files.

I rebased the changes

@mrahs mrahs merged commit 8a36686 into bazelbuild:master Apr 25, 2024
6 checks passed
@danw danw deleted the uuid branch April 25, 2024 17:01
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.

2 participants