From 85e1d8517d097163955b7a25ffbece2626e1d8eb Mon Sep 17 00:00:00 2001 From: Dave Try Date: Wed, 12 Jul 2023 10:16:31 -0500 Subject: [PATCH] wolfi: cadvisor entrypoint (#54809) Fixes the cadvisor entry point, which was being split onto new lines, meaning we were dropping some metrics like memory as reported by @michaellzc. As part of the testing I tried just downloading the binary from github, rather than building it from scratch. That didn't turn out to the final solution so that's an OPTIONAL leave in, but to me seems like an easier approach than compiling ourselves. With a rebuild of the base image we're also now running cadvisor 0.47.3 Old (working): ``` "Entrypoint": [ .... "-enable_metrics=cpu,diskIO,memory,network", .... ], ``` New (broken): ``` "Entrypoint": [ "/usr/bin/cadvisor", .... "-enable_metrics=cpu", "diskIO", "memory", "network", .... ``` Tested on scaletesting.sgdev.org image vs sourcegraph.com image (cherry picked from commit 054439411834940cf45f1e5afa4e5c72722d439d) --- dev/oci_deps.bzl | 2 +- docker-images/cadvisor/BUILD.bazel | 32 ++++++------ docker-images/cadvisor/entrypoint.sh | 12 +++++ wolfi-images/cadvisor.yaml | 2 +- wolfi-packages/cadvisor.yaml | 74 ---------------------------- 5 files changed, 32 insertions(+), 90 deletions(-) create mode 100755 docker-images/cadvisor/entrypoint.sh delete mode 100644 wolfi-packages/cadvisor.yaml diff --git a/dev/oci_deps.bzl b/dev/oci_deps.bzl index ad7820550c36..358cc1104f7d 100644 --- a/dev/oci_deps.bzl +++ b/dev/oci_deps.bzl @@ -24,7 +24,7 @@ def oci_deps(): oci_pull( name = "wolfi_cadvisor_base", - digest = "sha256:2e5aec9ba5a4835b4c35103bd27ad2ad3e65a064ec5001a35168044dd8c06a4a", + digest = "sha256:39f800ff006bbe579c71eaecc0157d5a57c7e2c0b11ba7a262eb8aec9fd848e0", image = "us.gcr.io/sourcegraph-dev/wolfi-cadvisor-base", ) diff --git a/docker-images/cadvisor/BUILD.bazel b/docker-images/cadvisor/BUILD.bazel index a031e5cffd25..36de2143eed4 100644 --- a/docker-images/cadvisor/BUILD.bazel +++ b/docker-images/cadvisor/BUILD.bazel @@ -1,24 +1,28 @@ load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball") load("@container_structure_test//:defs.bzl", "container_structure_test") load("//dev:oci_defs.bzl", "image_repository") +load("@rules_pkg//:pkg.bzl", "pkg_tar") + +filegroup( + name = "cadvisor_entrypoint", + srcs = ["entrypoint.sh"], +) + +pkg_tar( + name = "tar_cadvisor", + srcs = [ + ":cadvisor_entrypoint", + ], + remap_paths = { + "/entrypoint.sh": "/usr/bin/entrypoint.sh", + }, +) oci_image( name = "image", base = "@wolfi_cadvisor_base", - cmd = ["--sampling.strategies-file=/etc/jaeger/sampling_strategies.json"], - entrypoint = [ - "/usr/bin/cadvisor", - "-logtostderr", - "-port=48080", - "-enable_metrics=cpu,diskIO,memory,network", - "-docker_only", - "-housekeeping_interval=10s", - "-max_housekeeping_interval=15s", - "-event_storage_event_limit=default=0", - "-v=3", - "-event_storage_age_limit=default=0", - "-containerd=/var/run/containerd/containerd.sock", - ], + entrypoint = ["/usr/bin/entrypoint.sh"], + tars = [":tar_cadvisor"], ) oci_tarball( diff --git a/docker-images/cadvisor/entrypoint.sh b/docker-images/cadvisor/entrypoint.sh new file mode 100755 index 000000000000..d8916ad78529 --- /dev/null +++ b/docker-images/cadvisor/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +/usr/bin/cadvisor \ + -enable_metrics=cpu,memory,disk,network \ + -logtostderr \ + -port=48080 \ + -docker_only \ + -housekeeping_interval=10s \ + -max_housekeeping_interval=15s \ + -event_storage_event_limit=default=0 \ + -v=3 \ + -event_storage_age_limit=default=0 \ + -containerd=/var/run/containerd/containerd.sock diff --git a/wolfi-images/cadvisor.yaml b/wolfi-images/cadvisor.yaml index 9db42a315190..8d9bffbae439 100644 --- a/wolfi-images/cadvisor.yaml +++ b/wolfi-images/cadvisor.yaml @@ -9,4 +9,4 @@ contents: ## cadvisor dependencies - cadvisor -# MANUAL REBUILD: Wed Jun 14 15:27:52 BST 2023 +# MANUAL REBUILD: Wed Jul 12 08:42:56 -05 2023 diff --git a/wolfi-packages/cadvisor.yaml b/wolfi-packages/cadvisor.yaml deleted file mode 100644 index 6411f5b72b49..000000000000 --- a/wolfi-packages/cadvisor.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# Loosely based on the cadvisor Dockerfile, without support for ipmctl -# https://github.com/google/cadvisor/blob/master/deploy/Dockerfile -package: - name: cadvisor - # libpfm version may also need updating - check cadvisor Dockerfile - version: 0.47.1 - epoch: 1 - description: "Analyzes resource usage and performance characteristics of running containers" - target-architecture: - - x86_64 - copyright: - - paths: - - "*" - attestation: 'Copyright 2014 The cAdvisor Authors' - license: 'Apache License 2.0' - dependencies: - runtime: - - device-mapper - - findutils - - ndctl - - thin-provisioning-tools - -environment: - contents: - repositories: - - https://packages.wolfi.dev/os - keyring: - - https://packages.wolfi.dev/os/wolfi-signing.rsa.pub - packages: - - wolfi-base - - busybox - - ca-certificates-bundle - - build-base - - cmake - - device-mapper - - findutils - - git - - go - - linux-headers - - ndctl-dev - - thin-provisioning-tools - -pipeline: - # Fetch and build libpfm - - uses: fetch - with: - uri: https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-4.11.0.tar.gz - expected-sha256: 5da5f8872bde14b3634c9688d980f68bda28b510268723cc12973eedbab9fecc - strip-components: 0 - - runs: | - pwd - export DBG="-g -Wall" - make -e -C libpfm-4.11.0 - make install -C libpfm-4.11.0 - -# Check out cadvisor - - uses: git-checkout - with: - repository: https://github.com/google/cadvisor - tag: v${{package.version}} - expected-commit: c7714a77f72d77936446cb45296a1ef305a06c11 - destination: /cadvisor -# Build cadvisor - - runs: | - cd /cadvisor - GO_FLAGS="-tags=libfpm,netgo" ./build/build.sh - - # Package libpfm and cadvisor - - runs: | - mkdir -p ${{targets.destdir}}/usr/bin/ - mkdir -p ${{targets.destdir}}/usr/local/lib/ - cp /cadvisor/_output/cadvisor ${{targets.destdir}}/usr/bin/cadvisor - cp /usr/local/lib/libpfm.so* ${{targets.destdir}}/usr/local/lib/ -