google / cadvisor

Analyzes resource usage and performance characteristics of running containers.
Other
16.85k stars 2.31k forks source link

Unable to build cAdvisor #3229

Open justshell opened 1 year ago

justshell commented 1 year ago

Reference: https://github.com/google/cadvisor/blob/master/docs/development/build.md

Issue:

# make build
>> building assets
can't load package: package github.com/kevinburke/go-bindata/go-bindata@latest: cannot use path@version syntax in GOPATH mode
make: *** [assets] Error 1

Steps to reproduce: Used docker image of centos:7

# docker run -ti centos:7 bash

Inside container:

# cat /etc/centos-release
> CentOS Linux release 7.9.2009 (Core)
# yum install -y wget make git
# wget https://github.com/google/cadvisor/archive/refs/tags/v0.47.0.tar.gz
# wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz
# tar -C /usr/local -xzf go1.14.linux-amd64.tar.gz
# export PATH=$PATH:/usr/local/go/bin
# tar xf v0.47.0.tar.gz
# cd cadvisor-0.47.0/
# go version
> go version go1.14 linux/amd64
# make build 
>> building assets
can't load package: package github.com/kevinburke/go-bindata/go-bindata@latest: cannot use path@version syntax in GOPATH mode
make: *** [assets] Error 1

Via golang 1.16 (which specified in go.mod file https://github.com/google/cadvisor/blob/master/go.mod#L3): still have an issue Also used docker image centos:7 as base

# go version
> go version go1.16 linux/amd64
# make build
>> building assets
go: downloading github.com/kevinburke/go-bindata v3.24.0+incompatible
>> building binaries
fatal: Not a git repository (or any of the parent directories): .git
>> building cadvisor
go: downloading k8s.io/klog/v2 v2.80.1
go: downloading github.com/abbot/go-http-auth v0.4.0
go: downloading github.com/prometheus/client_golang v1.14.0
go: downloading k8s.io/utils v0.0.0-20211116205334-6203023598ed
go: downloading google.golang.org/api v0.104.0
go: downloading gopkg.in/olivere/elastic.v2 v2.0.61
go: downloading github.com/influxdb/influxdb v0.9.6-0.20151125225445-9eab56311373
go: downloading github.com/Shopify/sarama v1.37.2
go: downloading github.com/gomodule/redigo v1.8.9
go: downloading github.com/docker/go-units v0.5.0
go: downloading github.com/opencontainers/runc v1.1.4
go: downloading github.com/aws/aws-sdk-go v1.35.24
go: downloading cloud.google.com/go v0.105.0
go: downloading cloud.google.com/go/compute v1.13.0
go: downloading cloud.google.com/go/compute/metadata v0.2.2
go: downloading github.com/go-logr/logr v1.2.3
go: downloading golang.org/x/crypto v0.1.0
go: downloading golang.org/x/net v0.4.0
go: downloading github.com/prometheus/client_model v0.3.0
go: downloading github.com/prometheus/common v0.38.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/procfs v0.8.0
go: downloading google.golang.org/protobuf v1.28.1
go: downloading golang.org/x/oauth2 v0.3.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/eapache/go-resiliency v1.3.0
go: downloading github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21
go: downloading github.com/eapache/queue v1.1.0
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/jcmturner/gofork v1.7.6
go: downloading github.com/jcmturner/gokrb5/v8 v8.4.3
go: downloading github.com/klauspost/compress v1.15.11
go: downloading github.com/pierrec/lz4/v4 v4.1.17
go: downloading github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
go: downloading github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible
go: downloading github.com/moby/sys/mountinfo v0.6.2
go: downloading golang.org/x/sys v0.3.0
go: downloading github.com/euank/go-kmsg-parser v2.0.0+incompatible
go: downloading github.com/cyphar/filepath-securejoin v0.2.3
go: downloading github.com/sirupsen/logrus v1.8.1
go: downloading github.com/Rican7/retry v0.3.1
go: downloading github.com/mesos/mesos-go v0.0.11
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78
go: downloading google.golang.org/grpc v1.51.0
go: downloading github.com/blang/semver v3.5.1+incompatible
go: downloading github.com/docker/docker v20.10.21+incompatible
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2
go: downloading github.com/golang/snappy v0.0.4
go: downloading github.com/hashicorp/errwrap v1.0.0
go: downloading github.com/jcmturner/dnsutils/v2 v2.0.0
go: downloading github.com/hashicorp/go-uuid v1.0.3
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/karrick/godirwalk v1.17.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534
go: downloading github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7
go: downloading github.com/containerd/ttrpc v1.1.0
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/opencontainers/image-spec v1.0.2
go: downloading github.com/docker/distribution v2.8.1+incompatible
go: downloading github.com/googleapis/gax-go/v2 v2.7.0
go: downloading go.opencensus.io v0.24.0
go: downloading github.com/jcmturner/rpc/v2 v2.0.3
go: downloading github.com/checkpoint-restore/go-criu/v5 v5.3.0
go: downloading github.com/containerd/console v1.0.3
go: downloading github.com/mrunalp/fileutils v0.5.0
go: downloading github.com/opencontainers/selinux v1.10.0
go: downloading github.com/vishvananda/netlink v1.1.0
go: downloading github.com/cilium/ebpf v0.7.0
go: downloading github.com/jmespath/go-jmespath v0.4.0
go: downloading github.com/godbus/dbus/v5 v5.0.6
go: downloading google.golang.org/genproto v0.0.0-20221206210731-b1a01be3a5f6
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.2.0
go: downloading github.com/jcmturner/aescts/v2 v2.0.0
go: downloading github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
go: downloading github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df
go: downloading golang.org/x/text v0.5.0
go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
/root/go/pkg/mod/github.com/klauspost/compress@v1.15.11/zstd/blockdec.go:17:2: //go:build comment without // +build comment
/root/go/pkg/mod/github.com/!shopify/sarama@v1.37.2/zstd.go:6:2: //go:build comment without // +build comment
make: *** [build] Error 1
# echo $?
2

Can anyone explain how to build it?

iwankgb commented 1 year ago

I am aware of at least one dependency of cAdvisor that requires go1.17. I'm afraid that you will have to try with more up-to-date version of Golang.

obourdon commented 1 year ago

The following worked for me:

sed -i -e 's?go-bindata/go-bindata?go-bindata?' /go/src/github.com/google/cadvisor/build/assets.sh

please note however that I am using GoLang 1.17.13

MariaFjodorowa commented 9 months ago

After a few unsuccessful attempts to build it using go get as described in build.md (also editing assets.sh as advised above has not helped), the following has worked with GoLang 1.17.13:

git clone https://github.com/google/cadvisor.git
cd cadvisor/
make build
sudo ./_output/cadvisor
KatachiNo commented 7 months ago

After a few unsuccessful attempts to build it using go get as described in build.md (also editing assets.sh as advised above has not helped), the following has worked with GoLang 1.17.13:

git clone https://github.com/google/cadvisor.git
cd cadvisor/
make build
sudo ./_output/cadvisor

It's worked for me. Thanks