iovisor / kubectl-trace

Schedule bpftrace programs on your kubernetes cluster using the kubectl
MIT License
2.04k stars 165 forks source link

Tried compiling using instructions from Readme - Got error about spdystream #164

Closed jallirs closed 3 years ago

jallirs commented 3 years ago

Hello :) ,

Random lurker here :), tried making a Dockerfile to compile this with. Using golang:1.16.6-alpine3.14 as a base, I encoutered a strange issue, that I don't think is related to the base image I'm using or the version of golang.

My Dockerfile:

FROM golang:1.16.6-alpine3.14

RUN go get -u github.com/iovisor/kubectl-trace/cmd/kubectl-trace

Steps I took to build: docker build .

Error:

#6 190.0 go get: github.com/docker/spdystream@v0.0.0-20160310174837-449fdfce4d96 updating to
#6 190.0    github.com/docker/spdystream@v0.2.0: parsing go.mod:
#6 190.0    module declares its path as: github.com/moby/spdystream
#6 190.0            but was required as: github.com/docker/spdystream
------
executor failed running [/bin/sh -c go get -u github.com/iovisor/kubectl-trace/cmd/kubectl-trace]: exit code: 1

I checked go.sum, and [it's] (https://github.com/iovisor/kubectl-trace/blob/3c218fede35e63b365d684a2206bd8d56a8b3682/go.sum#L127) actually pointing to :

github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg=

But, the repo itself, on the newest release includes a note reading:

If you need to use the older docker/spdystream as import, please use the 0.1.0 tag.

I could do a PS to fix this if there's interest? I'm sure someone already has one #53 Please let me know if you feel like this isn't a valid issue or there's something else I should try. Also, awesome tool :)

dalehamel commented 3 years ago

I also get an error (though a different one) when I try to build with go1.15.7, on linux:

$ go get -u github.com/iovisor/kubectl-trace/cmd/kubectl-trace
package io/fs: unrecognized import path "io/fs": import path does not begin with hostname
cannot find package "github.com/pierrec/lz4/v4" in any of:
        /usr/lib/go/src/github.com/pierrec/lz4/v4 (from $GOROOT)
        /home/dale.hamel/workspace/go/src/github.com/pierrec/lz4/v4 (from $GOPATH)

However, when building via the Makefile, the build works. The command it ends up running is (by simply running make, and letting it build the default target):

CGO_ENABLED=1 go build -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=1627520106 -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit=568a278fe4110c151b2feabbe03aa2f1dd907482 -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageName=quay.io/iovisor/kubectl-trace-runner -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageTag=568a278fe4110c151b2feabbe03aa2f1dd907482 -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageName=quay.io/iovisor/kubectl-trace-init -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageTag=568a278fe4110c151b2feabbe03aa2f1dd907482' -o _output/bin/kubectl-trace ./cmd/kubectl-trace

I think the issue likely has something to do with go modules.

Can you try cloning the repo and building with Make as a workaround?

If you are able to submit a patch so that building via go get works, that would be great. Otherwise, we should probably remove it from the readme.

jallirs commented 3 years ago

I think the issue likely has something to do with go modules. Agreed :)

Can you try cloning the repo and building with Make as a workaround?

Literally just did, works :) .

Output:

go: downloading github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 go: downloading google.golang.org/grpc v1.38.0 go: downloading go.opencensus.io v0.23.0 go: downloading github.com/go-openapi/jsonpointer v0.19.3 go: downloading github.com/go-openapi/jsonreference v0.19.3 go: downloading github.com/go-openapi/swag v0.19.5 go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e go: downloading github.com/mattn/go-isatty v0.0.12 go: downloading github.com/BurntSushi/toml v0.3.1 go: downloading github.com/evanphx/json-patch/v5 v5.1.0 go: downloading github.com/pelletier/go-toml v1.8.0 go: downloading github.com/PuerkitoBio/purell v1.1.1 go: downloading github.com/mailru/easyjson v0.7.0 go: downloading github.com/ghodss/yaml v1.0.0 go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 go: downloading github.com/emicklei/go-restful v2.9.5+incompatible rm -f -R _output rm -f -R dist CGO_ENABLED=1 go build -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=1627520967 -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit= -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageName=quay.io/iovisor/kubectl-trace-runner -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageTag= -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageName=quay.io/iovisor/kubectl-trace-init -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageTag=' -o _output/bin/kubectl-trace ./cmd/kubectl-trace ~/kubectl-trace # cd _output/ ~/kubectl-trace/_output # ls bin ~/kubectl-trace/_output # cd bin/ ~/kubectl-trace/_output/bin # ls kubectl-trace

Doing this also works:

docker run -it --rm golang:1.16.6-alpine3.14 /bin/sh /go # go get -u github.com/docker/spdystream@v0.0.0-20160310174837-449fdfce4d96 go: downloading github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96

All around strange :(

But as long as there's a workaround, I'm cool with this :) .

dalehamel commented 3 years ago

Ok I think I've figured it out, the following succeeds:

GO111MODULE=on go get github.com/iovisor/kubectl-trace/cmd/kubectl-trace@latest

The following fails, with the same error you posted:

$ GO111MODULE=on go get -u github.com/iovisor/kubectl-trace/cmd/kubectl-trace@latest
...
go get: github.com/docker/spdystream@v0.0.0-20160310174837-449fdfce4d96 updating to
        github.com/docker/spdystream@v0.2.0: parsing go.mod:
        module declares its path as: github.com/moby/spdystream
                but was required as: github.com/docker/spdystream

I think this is because it is trying to bump the modules, and one of the things we depend on (probably client-go) is having issues because of this repo being renamed (though, that was a long time ago, so that's odd).

I'll update the README to reflect at least a working command, the former.

dalehamel commented 3 years ago

https://github.com/iovisor/kubectl-trace/pull/165 should fix this