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

cmd/go: panics on error during downgrade #31942

Closed
heschi opened this issue May 9, 2019 · 3 comments
Closed

cmd/go: panics on error during downgrade #31942

heschi opened this issue May 9, 2019 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@heschi
Copy link
Contributor

heschi commented May 9, 2019

What version of Go are you using (go version)?

$ go version
go version devel +f0c383b833 Wed May 1 16:53:19 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What did you do?

Note: this used to reproduce both with and without GOPROXY=https://proxy.golang.org but now only reproduces with the mirror. Presumably something changed upstream that hasn't made it to the mirror yet.

$ cd $(mktemp -d)
$ go mod init example.com
$ go mod init example.com
go: creating new go.mod: module example.com
$ go get -u cloud.google.com/go@master
[snip]
$ go get -u cloud.google.com/go@master
go: finding cloud.google.com/go master
go: finding github.com/googleapis/gax-go/v2 v2.0.0
go: github.com/googleapis/gax-go/v2@v2.0.0: unexpected status (https://proxy.golang.org/github.com/googleapis/gax-go/v2/@v/v2.0.0.info): 410 Gone                                                                                            
panic: error loading module requirements

goroutine 1 [running]:
cmd/go/internal/mvs.Downgrade.func2(0xc00024a3c0, 0x1f, 0xc00056a6c0, 0x6)
        /usr/lib/google-golang/src/cmd/go/internal/mvs/mvs.go:317 +0x659
cmd/go/internal/mvs.Downgrade(0xc00028c810, 0xb, 0x0, 0x0, 0xbdf500, 0xc0001d6000, 0xc00044c040, 0x1, 0x1, 0x0, ...)
        /usr/lib/google-golang/src/cmd/go/internal/mvs/mvs.go:349 +0x617
cmd/go/internal/modget.runGet(0xfd0d40, 0xc000020130, 0x1, 0x1)
        /usr/lib/google-golang/src/cmd/go/internal/modget/get.go:446 +0x1ed6
main.main()
        /usr/lib/google-golang/src/cmd/go/main.go:219 +0x837

What did you expect to see?

No panic.

What did you see instead?

Panic.

https://github.com/golang/go/blob/go1.12.5/src/cmd/go/internal/mvs/mvs.go#L317

@lopezator
Copy link

lopezator commented May 14, 2019

I've got bitten by this also.

go version go1.12.5 darwin/amd64

Also reproducible on tip:

go version devel +45d74aa Tue May 14 00:50:42 2019 +0000 darwin/amd64

Steps to reproduce:

After doing:

mkdir test
go mod init
go get github.com/volatiletech/sqlboiler@v2.5.1

Any of these (among others), fails with the same error:

go get google.golang.org/grpc@c443156028b9fa563e063e9fa8ba7881d467833b

go get google.golang.org/genproto@595979c8a7bf586b2d293fb42246bf91a0b893d9

go get github.com/golang/protobuf@17ce1425424ab154092bbb43af630bd647f3bb0d

go get golang.org/x/net@02ac38e2528ff4adea90f184d71a3faa04b4b1b0

go get golang.org/x/sys@7a4fde3fda8ef580a89dbae8138c26041be14299

go get golang.org/x/text@836efe42bb4aa16aaa17b9c155d8813d336ed720

Error

panic: github.com/googleapis/gax-go/v2@v2.0.0: missing github.com/googleapis/gax-go/go.mod and .../v2/go.mod at revision v2.0.0

goroutine 1 [running]:
cmd/go/internal/mvs.Downgrade.func2(0xc00025e720, 0x1f, 0xc00035121a, 0x6)
	/Users/d.lopez/sdk/gotip/src/cmd/go/internal/mvs/mvs.go:409 +0x676
cmd/go/internal/mvs.Downgrade(0xc0000240c0, 0x33, 0x0, 0x0, 0x1711ec0, 0xc0004c53b0, 0xc0000e7820, 0x1, 0x1, 0x0, ...)
	/Users/d.lopez/sdk/gotip/src/cmd/go/internal/mvs/mvs.go:441 +0x5c7
cmd/go/internal/modget.runGet(0x1a77220, 0xc0000c0050, 0x1, 0x1)
	/Users/d.lopez/sdk/gotip/src/cmd/go/internal/modget/get.go:563 +0x2e8a
main.main()
	/Users/d.lopez/sdk/gotip/src/cmd/go/main.go:188 +0x57f

@bcmills bcmills added this to the Go1.13 milestone May 14, 2019
@jayconrod
Copy link
Contributor

Oh this is fun.

When we downgrade a module, we consider the full module version graph, excluding newer versions of the downgraded module and anything else that requires newer versions. Then we do MVS on whatever's left.

When we require cloud.google.com/go v0.39.1-0.20190513200544-741d62a9e2a8 (the current master), that implies github.com/googleapis/gax-go/v2 v2.0.4. That requires something that gets excluded, so we try to downgrade to an earlier version. However, gax-go didn't migrate to modules until v2.0.3. v2.0.2 don't have go.mod files, so it's an error to depend on them. They should probably be considered part of the module github.com/googleapis/gax-go with a +incompatible suffix, but we don't see that for v2+ modules.

Even if we stopped returning these versions for the v2 module, GOPROXY will serve them forever. This is an easy mistake to make, and the Go command ought to recover from it when downgrading. Fortunately, this shouldn't affect upgrades or anyone getting the module at latest.

One possible fix: if Reqs.Required returns an error for a previous version of a module during a downgrade, we could silently exclude the version. It's currently hard to distinguish between transient errors (we couldn't reach the repository) and permanent errors (we couldn't parse the go.mod), but I think that's the right thing to do.

@jayconrod jayconrod added the NeedsFix The path to resolution is known, but the work has not been done. label May 14, 2019
@gopherbot
Copy link

Change https://golang.org/cl/177337 mentions this issue: cmd/go: don't attempt to downgrade to incompatible versions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants