Golang build fails to download dependencies

We are experiencing build failures on travis-ci/worker, which appear to be as a result of a network error. There were no changes to .snapcraft.yml on our side (except of updating go/1.12 => go/1.13, but we had the same error before this change)

Cloning into 'travis-worker'...
[24/Feb/2020:10:59:00 +0000] "CONNECT github.com:443 HTTP/1.1" 200 5883777 "-" "git/2.17.1"
Running pull phase...
snapd is not logged in, snap install commands will use sudo
go (1.13/stable) 1.13.8 from Michael Hudson-Doyle (mwhudson) installed
snapd is not logged in, snap install commands will use sudo
go 1.13.8 from Michael Hudson-Doyle (mwhudson) refreshed
[24/Feb/2020:10:59:13 +0000] "CONNECT api.snapcraft.io:443 HTTP/1.0" 200 14067 "-" "-"
Pulling travis-worker 
go: directory github.com/travis-ci/worker is outside main module
go: directory github.com/travis-ci/worker/backend is outside main module
go: directory github.com/travis-ci/worker/cmd/travis-worker is outside main module
go: directory github.com/travis-ci/worker/config is outside main module
go: directory github.com/travis-ci/worker/context is outside main module
go: directory github.com/travis-ci/worker/errors is outside main module
go: directory github.com/travis-ci/worker/image is outside main module
go: directory github.com/travis-ci/worker/metrics is outside main module
go: directory github.com/travis-ci/worker/ratelimit is outside main module
go: directory github.com/travis-ci/worker/remote is outside main module
go: directory github.com/travis-ci/worker/ssh is outside main module
go: directory github.com/travis-ci/worker/winrm is outside main module
[24/Feb/2020:10:59:15 +0000] "CONNECT proxy.golang.org:443 HTTP/1.1" 200 42307 "-" "Go-http-client/1.1"
go get -t -d ./github.com/travis-ci/worker/...
Failed to run 'go get -t -d ./github.com/travis-ci/worker/...' for 'travis-worker': Exited with code 1.
Verify that the part is using the correct parameters and try again.
Build failed

Example: https://build.snapcraft.io/user/travis-ci/worker/845743

I’ve tried to run build locally using steps described in “To debug this build” section, and it works just fine.

Well I’m not quite sure how to translate the “is outside main module” error (warning? info?). Perhaps a go expert could weigh in on that one…

Regardless, I just fired off a build to see if it was a temporary network issue. It does appear to build fine now without the “outside main module” statements [1]. If you retry the build and it still fails, that would be interesting to know.

[1] https://launchpadlibrarian.net/466713447/buildlog_snap_ubuntu_bionic_amd64_snapcraft-travis-worker-1329c3_BUILDING.txt.gz

Hi Chris, thanks for your reply. Unfortunately, it still fails with the same errors: https://build.snapcraft.io/user/travis-ci/worker/849911

Here is local output for comparison:

vagrant@ubuntu-bionic:~/worker$ snapcraft build --use-lxd --debug

The LXD provider is offered as a technology preview for early adopters.

The command line interface, container names or lifecycle handling may change in upcoming releases.

Launching a container.

Waiting for cloud-init

.......................

status: done

error: no changes of type "auto-refresh" found

snapd 2.43.3 from Canonical✓ refreshed

snapd is not logged in, snap install commands will use sudo

go (1.13/stable) 1.13.8 from Michael Hudson-Doyle (mwhudson) refreshed

Updating pull step for travis-worker (source changed)

go get -t -d ./github.com/travis-ci/worker/...

go get -t -d github.com/travis-ci/worker/cmd/travis-worker

Skipping pull wrappers (already ran)

Updating build step for travis-worker ('pull' step changed)

+ cd /root/project

+ git describe --always --dirty --tags

+ VERSION=v6.2.9

+ git rev-parse HEAD

+ REVISION=f334011e25057cd7d0fb57bd89ec186d2bd16548

+ REVISION_URL=https://github.com/travis-ci/worker/tree/f334011e25057cd7d0fb57bd89ec186d2bd16548

+ date -u +%Y-%m-%dT%H:%M:%S%z

+ GENERATED=2020-02-26T18:11:58+0000

+ grep -i ^copyright LICENSE

+ sed s/^[Cc]opyright //

+ COPYRIGHT=© 2018 Travis CI GmbH

+ cd -

/root/parts/travis-worker/build

+ sed -i s#VersionString =.*#VersionString = "v6.2.9"#g ../go/src/github.com/travis-ci/worker/version.go

+ sed -i s#RevisionString =.*#RevisionString = "f334011e25057cd7d0fb57bd89ec186d2bd16548"#g ../go/src/github.com/travis-ci/worker/version.go

+ sed -i s#RevisionURLString =.*#RevisionURLString = "https://github.com/travis-ci/worker/tree/f334011e25057cd7d0fb57bd89ec186d2bd16548"#g ../go/src/github.com/travis-ci/worker/version.go

+ sed -i s#GeneratedString =.*#GeneratedString = "2020-02-26T18:11:58+0000"#g ../go/src/github.com/travis-ci/worker/version.go

+ sed -i s#CopyrightString =.*#CopyrightString = "© 2018 Travis CI GmbH"#g ../go/src/github.com/travis-ci/worker/version.go

+ set +ex

go build -o /root/parts/travis-worker/go/bin/travis-worker github.com/travis-ci/worker/cmd/travis-worker

Skipping build wrappers (already ran)

vagrant@ubuntu-bionic:~/worker$ echo $?

0

Well I think I finally sorted this one out. It looks like multiple issues at play.

  • golang seems to have a bug (?) in this scenario, or we’re using it wrong…
    • 1.13.8 produces the above message
    • 1.14 (from the snap) crashes on go get
    • setting GO111MODULE=off appears to fix the behavior for 1.13 and 1.14
  • proper go.mod support is in snapcraft 3.10, not 3.9 (the current stable version that build.snapcraft.io uses)
  • the YAML specifies the go version in build-snaps. However, the go plugin has a property go-channel which sets the go snap version. The default value is latest/stable, so 1.13.8 (the current latest/stable) ends up installed regardless of whats in the build-snaps.

Regardless, I opened up a PR to address these issues with a suitable explanation: https://github.com/travis-ci/worker/pull/629 :smile:

2 Likes

Whoa! Thank a lot for you help, Chris.

1 Like