From: Arun Kumar Mohan Date: Sun, 2 Apr 2023 02:28:16 +0000 (+0530) Subject: ceph-mixin: fix ceph-mixin setup X-Git-Tag: testing/wip-pdonnell-testing-20240430.123648-reef-debug~18^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=211dfeb6ecb0c5d1f8764c2ad5315765bc7d785f;p=ceph-ci.git ceph-mixin: fix ceph-mixin setup Made following changes to files, Makefile: Add needed 'tox' target to generate alert files Now we can do 'make generate' OR 'make test' to generate all the yaml files (and run tests) alerts.jsonnet: Added an 'import' line to include 'config.libsonnet' file. This fix the errors in generating 'prometheus_alerts.yml' file tox.ini: Added all the existing 'alerts-' targets to 'envlist' Added the missing 'alerts-test' target to 'testenv' Added 'jsonnet' to 'allowlist_externals', which prevents a deprecation waring A minor spell correction lint-jsonnet.sh: Made errors more verbose. Signed-off-by: Arun Kumar Mohan (cherry picked from commit 86d040e2fcf44585f113d94622b275ca5c2b6c76) --- diff --git a/monitoring/ceph-mixin/Makefile b/monitoring/ceph-mixin/Makefile index 0cb7aa5393c..915481d8c14 100644 --- a/monitoring/ceph-mixin/Makefile +++ b/monitoring/ceph-mixin/Makefile @@ -4,6 +4,7 @@ fmt: ./lint-jsonnet.sh -i generate: dashboards_out + tox -ealerts-fix vendor: jsonnetfile.lock.json tox -ejsonnet-bundler-install @@ -18,7 +19,7 @@ lint: test: generate tox -ejsonnet-check tox -epromql-query-test - tox -ealerts-check + tox -ealerts-test check: test .PHONY: all fmt generate lint test check diff --git a/monitoring/ceph-mixin/alerts.jsonnet b/monitoring/ceph-mixin/alerts.jsonnet index 43826eedd21..ab7907c76fd 100644 --- a/monitoring/ceph-mixin/alerts.jsonnet +++ b/monitoring/ceph-mixin/alerts.jsonnet @@ -1 +1 @@ -std.manifestYamlDoc((import 'alerts.libsonnet').prometheusAlerts, indent_array_in_object=true, quote_keys=false) +std.manifestYamlDoc(((import 'config.libsonnet') + (import 'alerts.libsonnet')).prometheusAlerts, indent_array_in_object=true, quote_keys=false) diff --git a/monitoring/ceph-mixin/lint-jsonnet.sh b/monitoring/ceph-mixin/lint-jsonnet.sh index 6f771626982..76424568453 100755 --- a/monitoring/ceph-mixin/lint-jsonnet.sh +++ b/monitoring/ceph-mixin/lint-jsonnet.sh @@ -1,5 +1,14 @@ #!/bin/sh -e JSONNETS_FILES=$(find . -name 'vendor' -prune -o \ - -name '*.jsonnet' -print -o -name '*.libsonnet' -print) -jsonnetfmt "$@" ${JSONNETS_FILES} + -name '*.jsonnet' -print -o -name '*.libsonnet' -print) +for each_jsonnet_file in ${JSONNETS_FILES}; do + jsonnetfmt "$@" ${each_jsonnet_file} || jfmt_failed_files="$jfmt_failed_files ${each_jsonnet_file}" +done +exit_status=0 +# if variable 'jfmt_failed_files' is not empty/null +if [ -n "${jfmt_failed_files}" ]; then + echo "'jsonnetfmt' check failed on:${jfmt_failed_files}" + exit_status=1 +fi +exit $exit_status diff --git a/monitoring/ceph-mixin/tox.ini b/monitoring/ceph-mixin/tox.ini index d0d97fc98b9..90ac311edba 100644 --- a/monitoring/ceph-mixin/tox.ini +++ b/monitoring/ceph-mixin/tox.ini @@ -4,7 +4,8 @@ envlist = jsonnet-{check,lint,fix}, jsonnet-bundler-{install,update}, promql-query-{test,lint}, - alerts-check + alerts-{fix,check,lint,test} + skipsdist = true [testenv:jsonnet-bundler-{install,update}] @@ -23,7 +24,7 @@ allowlist_externals = find jb jsonnet - jsonnetfm + jsonnetfmt sh description = check: Ensure that auto-generated files matches the current version @@ -61,13 +62,14 @@ allowlist_externals = commands = behave tests_dashboards/features -[testenv:alerts-{fix,check,lint}] +[testenv:alerts-{fix,check,lint,test}] deps = -rrequirements-alerts.txt pytest depends = grafonnet-check allowlist_externals = promtool + jsonnet commands = fix: jsonnet -J vendor -S alerts.jsonnet -o prometheus_alerts.yml lint: promtool check rules prometheus_alerts.yml