Skip to content

Commit

Permalink
Merge remote-tracking branch 'google/master' into avoid_scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
iwankgb committed Jun 28, 2024
2 parents 5814a54 + 89f779d commit 0e4ca6b
Show file tree
Hide file tree
Showing 55 changed files with 982 additions and 442 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ jobs:
test:
strategy:
matrix:
go-versions: ['1.20', '1.19']
platform: [ubuntu-20.04]
go-versions: ['1.22', '1.21']
platform: [ubuntu-22.04]
environment-variables: [build/config/plain.sh, build/config/libpfm4.sh, build/config/libipmctl.sh]
runs-on: ${{ matrix.platform }}
timeout-minutes: 30
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-versions }}
check-latest: true
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run presubmit checks
run: |
source ${{ matrix.environment-variables }}
Expand All @@ -30,14 +31,14 @@ jobs:
test-integration:
strategy:
matrix:
go-versions: ['1.20', '1.19']
platform: [ubuntu-20.04]
go-versions: ['1.22', '1.21']
platform: [ubuntu-22.04]
environment-variables: [build/config/plain.sh, build/config/libpfm4.sh, build/config/libipmctl.sh]
runs-on: ${{ matrix.platform }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run integration tests
env:
GOLANG_VERSION: ${{ matrix.go-versions }}
Expand All @@ -46,7 +47,7 @@ jobs:
source ${{ matrix.environment-variables }}
make docker-test-integration
- name: Upload cAdvisor log file
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure()
with:
name: cadvisor.log
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

GO := go
GOLANGCI_VER := v1.51.2
GOLANGCI_VER := v1.56.2
GO_TEST ?= $(GO) test $(or $(GO_FLAGS),-race)
arch ?= $(shell go env GOARCH)

Expand Down Expand Up @@ -72,7 +72,7 @@ docker-%:
@docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile .

docker-build:
@docker run --rm -w /go/src/github.com/google/cadvisor -v ${PWD}:/go/src/github.com/google/cadvisor golang:1.20 make build
@docker run --rm -w /go/src/github.com/google/cadvisor -v ${PWD}:/go/src/github.com/google/cadvisor golang:1.22 make build

presubmit: lint
@echo ">> checking go mod tidy"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cAdvisor has native support for [Docker](https://github.com/docker/docker) conta
To quickly tryout cAdvisor on your machine with Docker, we have a Docker image that includes everything you need to get started. You can run a single cAdvisor to monitor the whole machine. Simply run:

```
VERSION=v0.36.0 # use the latest release version from https://github.com/google/cadvisor/releases
VERSION=v0.49.1 # use the latest release version from https://github.com/google/cadvisor/releases
sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:ro \
Expand Down
2 changes: 1 addition & 1 deletion build/check_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
target_image=$1

# Architectures officially supported by cadvisor
arches=( "amd64" "arm" "arm64" "s390x" )
arches=( "amd64" "arm" "arm64" )

# Docker doesn't handle images with different architectures but the same tag.
# Remove the container and the image use by it to avoid problems.
Expand Down
4 changes: 2 additions & 2 deletions build/config/libipmctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# limitations under the License.

export GO_FLAGS="-tags=libipmctl,cgo -race"
export PACKAGES="sudo libipmctl4"
export BUILD_PACKAGES="libipmctl4 libipmctl-dev"
export PACKAGES="sudo libipmctl5"
export BUILD_PACKAGES="libipmctl5 libipmctl-dev"
export CADVISOR_ARGS="-perf_events_config=perf/testing/perf-non-hardware.json"
17 changes: 7 additions & 10 deletions build/integration-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ function run_tests() {
env GOOS=linux GOFLAGS='$GO_FLAGS' go test -c github.com/google/cadvisor/integration/tests/healthz"

if [ "$BUILD_PACKAGES" != "" ]; then
BUILD_CMD="echo 'deb http://deb.debian.org/debian buster-backports main'>/etc/apt/sources.list.d/buster.list && \
apt update && \
apt install -y -t buster-backports $BUILD_PACKAGES && \
BUILD_CMD="apt update && apt install -y $BUILD_PACKAGES && \
$BUILD_CMD"
fi
docker run --rm \
-w /go/src/github.com/google/cadvisor \
-v ${PWD}:/go/src/github.com/google/cadvisor \
golang:"$GOLANG_VERSION-buster" \
golang:"$GOLANG_VERSION-bookworm" \
bash -c "$BUILD_CMD"

EXTRA_DOCKER_OPTS="-e DOCKER_IN_DOCKER_ENABLED=true"
Expand All @@ -60,17 +58,16 @@ function run_tests() {
--privileged \
--cap-add="sys_admin" \
--entrypoint="" \
gcr.io/k8s-testimages/bootstrap \
bash -c "echo 'deb http://deb.debian.org/debian buster-backports main'>/etc/apt/sources.list.d/buster.list && \
cat /etc/apt/sources.list.d/buster.list && \
gcr.io/k8s-staging-test-infra/bootstrap \
bash -c "export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt install -y -t buster-backports $PACKAGES && \
CADVISOR_ARGS="$CADVISOR_ARGS" /usr/local/bin/runner.sh build/integration.sh"
apt install -y $PACKAGES && \
CADVISOR_ARGS=$CADVISOR_ARGS /usr/local/bin/runner.sh build/integration.sh"
}

GO_FLAGS=${GO_FLAGS:-"-tags=netgo -race"}
PACKAGES=${PACKAGES:-"sudo"}
BUILD_PACKAGES=${BUILD_PACKAGES:-}
CADVISOR_ARGS=${CADVISOR_ARGS:-}
GOLANG_VERSION=${GOLANG_VERSION:-"1.20"}
GOLANG_VERSION=${GOLANG_VERSION:-"1.22"}
run_tests "$GO_FLAGS" "$PACKAGES" "$BUILD_PACKAGES" "$CADVISOR_ARGS"
4 changes: 2 additions & 2 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ docker buildx inspect cadvisor-builder > /dev/null \
# Build binaries

# A mapping of the docker arch name to the qemu arch name
declare -A arches=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["s390x"]="s390x")
declare -A arches=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" )

for arch in "${arches[@]}"; do
if ! hash "qemu-${arch}-static"; then
Expand All @@ -71,7 +71,7 @@ done
for arch in "${!arches[@]}"; do
GOARCH="$arch" GO_CGO_ENABLED="0" OUTPUT_NAME_WITH_ARCH="true" build/build.sh
arch_specific_image="${image_name}-${arch}:${VERSION}"
docker buildx build --platform "linux/${arch}" --build-arg VERSION="$VERSION" -f deploy/Dockerfile -t "$arch_specific_image" --progress plain --push .
docker buildx build --platform "linux/${arch}" --provenance=false --build-arg VERSION="$VERSION" -f deploy/Dockerfile -t "$arch_specific_image" --progress plain --push .
docker manifest create --amend "$final_image" "$arch_specific_image"
docker manifest annotate --os=linux --arch="$arch" "$final_image" "$arch_specific_image"
done
Expand Down
2 changes: 1 addition & 1 deletion build/unit-in-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ function run_tests() {

GO_FLAGS=${GO_FLAGS:-"-tags=netgo -race"}
BUILD_PACKAGES=${BUILD_PACKAGES:-}
GOLANG_VERSION=${GOLANG_VERSION:-"1.20"}
GOLANG_VERSION=${GOLANG_VERSION:-"1.22"}
run_tests
5 changes: 2 additions & 3 deletions cmd/cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ func init() {
optstr := container.AllMetrics.String()
flag.Var(&ignoreMetrics, "disable_metrics", fmt.Sprintf("comma-separated list of `metrics` to be disabled. Options are %s.", optstr))
flag.Var(&enableMetrics, "enable_metrics", fmt.Sprintf("comma-separated list of `metrics` to be enabled. If set, overrides 'disable_metrics'. Options are %s.", optstr))

// Default logging verbosity to V(2)
_ = flag.Set("v", "2")
}

func main() {
klog.InitFlags(nil)
defer klog.Flush()
// Default logging verbosity to V(2)
_ = flag.Set("v", "2")
flag.Parse()

if *versionFlag {
Expand Down
79 changes: 45 additions & 34 deletions cmd/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/google/cadvisor/cmd

go 1.19
go 1.21

// Record that the cmd module requires the cadvisor library module.
// The github.com/google/cadvisor/cmd module is built using the Makefile
Expand All @@ -23,47 +23,51 @@ require (
github.com/onsi/gomega v1.24.1 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect
github.com/prometheus/client_golang v1.14.0
github.com/stretchr/testify v1.8.2
golang.org/x/oauth2 v0.4.0
google.golang.org/api v0.104.0
github.com/stretchr/testify v1.9.0
golang.org/x/oauth2 v0.18.0
google.golang.org/api v0.169.0
gopkg.in/olivere/elastic.v2 v2.0.61
k8s.io/klog/v2 v2.100.1
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
)

require (
cloud.google.com/go/compute v1.15.1 // indirect
cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.4.15 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go v1.35.24 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/containerd/ttrpc v1.2.4 // indirect
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.21+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v26.1.4+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand All @@ -75,15 +79,16 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/mrunalp/fileutils v0.5.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/mrunalp/fileutils v0.5.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 // indirect
github.com/opencontainers/runc v1.1.13 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opencontainers/selinux v1.10.0 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -92,22 +97,28 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/vishvananda/netlink v1.1.0 // indirect
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 0e4ca6b

Please sign in to comment.