From 52bf88bf164aa2c1b4b6e940d922f523ba870579 Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Tue, 27 Aug 2024 11:09:17 -0400 Subject: [PATCH 1/2] Run `mixtool` in container Also updates mixtool to latest version which closes https://github.com/grafana/mimir/issues/1617 Mixtool was actually updated two months ago, so the dashboards are already all compliant! For the Makefile changes, I was looking at the issue above and I wanted to test it using the build image. I noticed that it wasn't actually running in the container. This should make it easier to test in the future. --- Makefile | 40 +++++++++++++++++++----------------- mimir-build-image/Dockerfile | 2 +- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 03b6b8a467..6d1aa5646b 100644 --- a/Makefile +++ b/Makefile @@ -300,7 +300,7 @@ GOVOLUMES= -v mimir-go-cache:/go/cache \ # Mount local ssh credentials to be able to clone private repos when doing `mod-check` SSHVOLUME= -v ~/.ssh/:/root/.ssh:$(CONTAINER_MOUNT_OPTIONS) -exes $(EXES) $(EXES_RACE) protos $(PROTO_GOS) lint lint-packaging-scripts test test-with-race cover shell mod-check check-protos doc format dist build-mixin format-mixin check-mixin-tests license check-license conftest-fmt check-conftest-fmt helm-conftest-test helm-conftest-quick-test conftest-verify check-helm-tests build-helm-tests print-go-version: fetch-build-image +exes $(EXES) $(EXES_RACE) protos $(PROTO_GOS) lint lint-packaging-scripts test test-with-race cover shell mod-check check-protos doc format dist build-mixin format-mixin check-mixin check-mixin-jb check-mixin-mixtool check-mixin-tests license check-license conftest-fmt check-conftest-fmt helm-conftest-test helm-conftest-quick-test conftest-verify check-helm-tests build-helm-tests print-go-version: fetch-build-image @echo ">>>> Entering build container: $@" $(SUDO) time docker run --rm $(TTY) -i $(SSHVOLUME) $(GOVOLUMES) $(BUILD_IMAGE) GOOS=$(GOOS) GOARCH=$(GOARCH) BINARY_SUFFIX=$(BINARY_SUFFIX) $@; @@ -586,6 +586,26 @@ check-mixin-tests: ## Test the mixin files. format-mixin: ## Format the mixin files. @find $(MIXIN_PATH) -type f -name '*.libsonnet' | xargs jsonnetfmt -i +check-mixin: ## Build, format and check the mixin files. +check-mixin: build-mixin format-mixin check-mixin-jb check-mixin-mixtool check-mixin-runbooks + @echo "Checking diff:" + @for suffix in $(MIXIN_OUT_PATH_SUFFIXES); do \ + ./tools/find-diff-or-untracked.sh $(MIXIN_PATH) "$(MIXIN_OUT_PATH)$$suffix" || (echo "Please build and format mixin by running 'make build-mixin format-mixin'" && false); \ + done + + @echo "Running mixtool version $$(mixtool --version)" + @cd $(MIXIN_PATH) && \ + jb install && \ + mixtool lint mixin.libsonnet + +check-mixin-jb: + @cd $(MIXIN_PATH) && \ + jb install + +check-mixin-mixtool: check-mixin-jb + @cd $(MIXIN_PATH) && \ + mixtool lint mixin.libsonnet + # Helm static tests HELM_SCRIPTS_PATH=operations/helm/scripts @@ -674,24 +694,6 @@ check-white-noise: ## Check the white noise in the markdown files. check-white-noise: clean-white-noise @git diff --exit-code -- '*.md' || (echo "Please remove trailing whitespaces running 'make clean-white-noise'" && false) -check-mixin: ## Build, format and check the mixin files. -check-mixin: build-mixin format-mixin check-mixin-jb check-mixin-mixtool check-mixin-runbooks - @echo "Checking diff:" - @for suffix in $(MIXIN_OUT_PATH_SUFFIXES); do \ - ./tools/find-diff-or-untracked.sh $(MIXIN_PATH) "$(MIXIN_OUT_PATH)$$suffix" || (echo "Please build and format mixin by running 'make build-mixin format-mixin'" && false); \ - done - - @cd $(MIXIN_PATH) && \ - jb install && \ - mixtool lint mixin.libsonnet - -check-mixin-jb: - @cd $(MIXIN_PATH) && \ - jb install - -check-mixin-mixtool: check-mixin-jb - @cd $(MIXIN_PATH) && \ - mixtool lint mixin.libsonnet check-mixin-runbooks: build-mixin @tools/lint-runbooks.sh diff --git a/mimir-build-image/Dockerfile b/mimir-build-image/Dockerfile index 433944976b..b42da67496 100644 --- a/mimir-build-image/Dockerfile +++ b/mimir-build-image/Dockerfile @@ -54,7 +54,7 @@ RUN GO111MODULE=on \ go install github.com/fatih/faillint@v1.12.0 && \ go install github.com/campoy/embedmd@v1.0.0 && \ go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.4.0 && \ - go install github.com/monitoring-mixins/mixtool/cmd/mixtool@b97ae11 && \ + go install github.com/monitoring-mixins/mixtool/cmd/mixtool@1aace356d01747eea16a2677ed13bdcbbd4bb082 && \ go install github.com/mikefarah/yq/v4@v4.13.4 && \ go install github.com/google/go-jsonnet/cmd/jsonnet@v0.19.1 && \ go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.19.1 && \ From cb13383295b6583ada0a029bc4b72fe6ca3c2653 Mon Sep 17 00:00:00 2001 From: julienduchesne Date: Tue, 27 Aug 2024 15:47:27 +0000 Subject: [PATCH 2/2] Update build image version to pr9117-daf8649bf3 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6d1aa5646b..d03a8ea0f6 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ mimir-build-image/$(UPTODATE): mimir-build-image/* # All the boiler plate for building golang follows: SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER ?= true -LATEST_BUILD_IMAGE_TAG ?= pr9070-5347ec889b +LATEST_BUILD_IMAGE_TAG ?= pr9117-daf8649bf3 # TTY is parameterized to allow Google Cloud Builder to run builds, # as it currently disallows TTY devices. This value needs to be overridden