google-cloud-go: storage: problematic dependency resolution with `stats`
Having upgraded from:
cloud.google.com/go/storage v1.46.0 -> cloud.google.com/go/storage v1.48.0, I get the following error:
<redacted>/go/pkg/mod/cloud.google.com/go/storage@v1.48.0/storage.go:264:25: undefined: stats.NewMetrics
This corresponds to:
… and I believe these two imports are in conflict:
I suspect that somehow, this NewMetrics is getting shadowed by https://pkg.go.dev/google.golang.org/grpc/stats/opentelemetry@v0.0.0-20241028142157-ada6787961b3 .
For a brief period, I was getting ambiguous import errors pointing at these two packages with go mod tidy. I’m no longer getting those errors, but I still fail to compile.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 28
- Comments: 29 (18 by maintainers)
Commits related to this issue
- Revert "Update vendored dependencies" This reverts commit b3ce3b8dbd8ebfabae6aa16d583d6edfed9def49. and commit 9a78ef5ff85505c47d4acbdbc307b271f54f7458. There is an issue with the cloud.google.com/g... — committed to cloudfoundry/bosh-cli by nader-ziada 2 years ago
- fix: Revert "fix(deps): Update module google.golang.org/grpc to v1.69.0" (#455) Reverts cloudquery/plugin-pb-go#447 until https://github.com/googleapis/google-cloud-go/issues/11283 is fixed otherwise... — committed to cloudquery/plugin-pb-go by erezrokah 2 years ago
- fix: Revert "fix(deps): Update module google.golang.org/grpc to v1.69.0" (#2018) #### Summary Same as https://github.com/cloudquery/plugin-pb-go/pull/455 for the SDK. We can do the update once ... — committed to cloudquery/plugin-sdk by erezrokah 2 years ago
- chore(go): update deps This update fixes compilation issues caused by googleapis/google-cloud-go#11283 — committed to tritone/storage-shared-benchmarking by tritone 2 years ago
- chore(go): update deps (#263) This update fixes compilation issues caused by googleapis/google-cloud-go#11283 — committed to googleapis/storage-shared-benchmarking by tritone 2 years ago
- chore: make go-update and make go-tidy This updates all of the go modules. I had to manually run these workarounds for the first time before make go-update and make go-tidy would work: - https://git... — committed to GoogleChrome/webstatus.dev by jcscottiii 2 years ago
- chore: make go-update and make go-tidy (#1019) This updates all of the go modules. I had to manually run these workarounds for the first time before make go-update and make go-tidy would work: - htt... — committed to GoogleChrome/webstatus.dev by jcscottiii 2 years ago
- chore: make go-update and make go-tidy (#1019) This updates all of the go modules. I had to manually run these workarounds for the first time before make go-update and make go-tidy would work: - htt... — committed to GoogleChrome/webstatus.dev by jcscottiii 2 years ago
- 🧹 update the grpc dependency Since grpc removed `google.golang.org/grpc/stats/opentelemetry` dependency but go mod has not picked this up, we needed to remove the indirect dependency manually. More ... — committed to mondoohq/cnquery by chris-rock 2 years ago
- 🧹 update the grpc dependency (#5068) Since grpc removed `google.golang.org/grpc/stats/opentelemetry` dependency but go mod has not picked this up, we needed to remove the indirect dependency manuall... — committed to mondoohq/cnquery by chris-rock 2 years ago
- Fix ambiguous imports in go workspaces Unclear why this happens only when I use a go workspace, but there's some underlying problem here. https://github.com/googleapis/google-cloud-go/issues/11283 — committed to mhutchinson/trillian-tessera by mhutchinson 2 years ago
- update dependency cloud.google.com/go/storage to v1.50.0 context here: https://github.com/googleapis/google-cloud-go/issues/11283 — committed to cloudfoundry/bosh-gcscli by nader-ziada 2 years ago
- vendor: run `make vendor-update` Add exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a to go.mod according to https://github.com/googleapis/google-cloud-go/issues/... — committed to VictoriaMetrics/VictoriaMetrics by valyala 2 years ago
- vendor: run `make vendor-update` Add exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a to go.mod according to https://github.com/googleapis/google-cloud-go/issues/... — committed to VictoriaMetrics/VictoriaMetrics by valyala 2 years ago
- chore: update indexer (#3050) https://github.com/google/osv.dev/pull/3030 failed to update indexer due to problematic dependency resolution. Following https://github.com/googleapis/google-cloud-... — committed to google/osv.dev by hogo6002 2 years ago
- vendor: run `make vendor-update` Add exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a to go.mod according to https://github.com/googleapis/google-cloud-go/issues/... — committed to VictoriaMetrics/VictoriaMetrics by valyala 2 years ago
- fix(grpc): update to fix ambiguous imports caused by grpc modules full context in https://github.com/googleapis/google-cloud-go/issues/11283 — committed to GoogleCloudPlatform/golang-samples by muncus 2 years ago
- fix(grpc): update to fix ambiguous imports caused by grpc modules (#5100) * fix(grpc): update to fix ambiguous imports caused by grpc modules full context in https://github.com/googleapis/google-c... — committed to GoogleCloudPlatform/golang-samples by muncus 2 years ago
- vendor: run `make vendor-update` Add exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a to go.mod according to https://github.com/googleapis/google-cloud-go/issues/... — committed to G-Research/VictoriaMetrics by valyala 2 years ago
- vendor: run `make vendor-update` Add exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a to go.mod according to https://github.com/googleapis/google-cloud-go/issues/... — committed to truepele/VictoriaMetrics by valyala 2 years ago
same issue here
The problem is that
google.golang.org/grpc/stats/opentelemetryis not its own module any more. This was changed between v1.68.1 and v1.69.0 ofgoogle.golang.org/grpc: https://github.com/grpc/grpc-go/pull/7759Upgrading to the latest
google.golang.org/grpcpackage will now cause the same package to be imported from two different sources. Upgradingstorageto use the latestgoogle.golang.org/grpcand dropping thegoogle.golang.org/grpc/stats/opentelemetrydependency should fix the issue.Facing the same issue as well.
You have to be kidding me. While this issue indeed seems to be fixed, github.com/envoyproxy/go-control-plane decided to join the party!
@tritone
It avoids the dependency resolution failing at least, for the repositories I’ve tried.
The non-manual way is
go mod edit --exclude=google.golang.org/grpc@v1.69.0.@dfawley I’m not sure this solves the issue. In
v1.69.0google.golang.org/grpc/stats/opentelemetryis a package of thegoogle.golang.org/grpcmodule. In previous versions ofgoogle.golang.org/grpcit is its own module.So you still have the problem where if you use both
cloud.google.com/go/storageandgoogle.golang.org/grpcas direct dependencies you cannot upgrade the later tov1.69.0without breaking the dependency tree because of ambiguous imports regarding the opentelemetry package.Example go.mod:
Then call
go mod tidy:The only solution seems to be to stick with an older version of
google.golang.org/grpcuntilcloud.google.com/go/storageis updated.Yes, or manually deleting the indirect dep on google.golang.org/grpc/stats/opentelemetry from the go.mod should also do the trick.
BTW, I had to
exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a:Okay, the latest release (storage v1.49.0) seems to fix the issue in my repro.
go get -u google.golang.org/grpc(can upgrade to latest release v1.69.2 or v1.67.3 for compatibility with go 1.21)go get -u cloud.google.com/go/storageYou may also have to remove
google.golang.org/grpc/stats/opentelemetryas an indirect dependency.Let me know if this resolves the issue for you all or if there are still any problems.
Apologies for the inconvenience here.
I have released grpc-go v1.67.3 that pulls in the previously-experimental module that cloud storage was using.
@StevenACoffman,
Just to clarify this a bit: after
cloud.google.com/**upgrades to grpc-go v1.67.3, you should be able to upgrade to grpc-go v1.69.x, since you (presumably) don’t have the Go 1.21 restriction. There should be no ambiguous import after that.Hey all, apologies for the issue here, we are working to fix this ASAP.
There is a workaround that should unblock compilation and
go getcalls, which is to exclude the latest release of grpc-go from your go.mod.exclude google.golang.org/grpc v1.69.0Let me know if this resolves this issue.
I believe the only (?) issue here is that grpc-go moved some of the symbols that cloud storage was relying upon from our
experimentaldirectory into a stable location, without leaving behind type aliases. If so, that’s our mistake and we will fix it ASAP. PR https://github.com/grpc/grpc-go/pull/7929 should address it, and we will do a patch release with it ASAP.Ugh. I’ll open a new issue here as well to track resolution, since it blocks updates for storage as well as other clients which have this as an indirect dependency (spanner, bigtable).
I haven’t heard from anyone still experiencing this issue, so I’m going to close this out. Thanks for your patience all.
Unfortunately in my repro,
go mod tidyalso didn’t work until the indirect dep was manually removed.@StevenACoffman I believe you summarized this well, yes.
@dfawley You are probably already aware, but I wanted to get confirmation that I understand the plan for my colleagues.
However:
So after you have merged #7935 and released grpc-go v1.67.3(?) , cloud.google.com/go/storage will need to update to that (not v1.68.x) and then cut a new release (maybe v1.50.0 since v1.49.0 release already has a PR for it and appears to be in progress). Then people can update to grpc-go v1.67.3(?) or cloud.google.com/go/storage v1.50.0(?) and not have an ambiguous update. In January, cloud.google.com/go/storage can update to Go 1.22 and updating to grpc-go v1.69.x+ becomes unblocked.
In the meantime,
go mod edit --exclude=google.golang.org/grpc@v1.69.0is the only workaround.@tritone @zasweq Is it possible to just add the
go.modback forstats/opentelemetrythat was removed in #7759 and cut a point release untilcloud.google.com/go/storageis ready to upgrade to minimum version of Go 1.22 (and drop Go 1.21) in January?Also, anything that imported the missing module will be unable to upgrade to gRPC-go 1.69: https://pkg.go.dev/google.golang.org/grpc/stats/opentelemetry?tab=importedby
@fasmat Thanks for confirming that the change above will not fully fix things. This document seems to indicate that such an operation is possible and valid, but it’s missing details on how to perform the removal – it just refers to the “adding a module” instructions and how to actually do it correctly is left as an exercise for the reader. In particular, splitting a module requires adding a dependency from the new module to a new version of the existing module, but when joining modules, I can’t add a dependency to the removed module, since no module exists there anymore.
So for now I’m not sure how to properly remove a module and move its packages to its parent module. (If it is possible as the wiki suggests.) I’ll keep working on this.
ok, updating everything and keeping
cloud.google.com/go/storage v1.46.0worked for me. will check back on this once google replies.Depends, the amount of code changed is minimal (I believe just a singe line of code). The rest is just replacing the current version of the dependency with the newest one and bumping Go everywhere where it’s still 1.21 to 1.22 🙂 The new grpc dependency requires at least 1.22.
I created a PR to update the GRPC dependency in all modules: https://github.com/googleapis/google-cloud-go/pull/11284