]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-mixin: fix ceph-mixin setup
authorArun Kumar Mohan <amohan@redhat.com>
Sun, 2 Apr 2023 02:28:16 +0000 (07:58 +0530)
committerArun Kumar Mohan <amohan@redhat.com>
Thu, 28 Mar 2024 08:19:49 +0000 (13:49 +0530)
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 <amohan@redhat.com>
(cherry picked from commit 86d040e2fcf44585f113d94622b275ca5c2b6c76)

monitoring/ceph-mixin/Makefile
monitoring/ceph-mixin/alerts.jsonnet
monitoring/ceph-mixin/lint-jsonnet.sh
monitoring/ceph-mixin/tox.ini

index 0cb7aa5393c297298a7cba78e47ede5a37c4fabc..915481d8c1437e452163fb0578c9d23163920201 100644 (file)
@@ -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
index 43826eedd21d963aaa326fcd9df93fcdf87a4893..ab7907c76fd1298b714923440a7491db0f322cf5 100644 (file)
@@ -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)
index 6f77162698246f643c7d2e0320a98f119ab27db7..764245684532e47094bfd246a31eb9ff574d6821 100755 (executable)
@@ -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
index d0d97fc98b9da0466718c8cfc9d9781b0cecdea5..90ac311edba7eabf9a81324c6023112677dacaa4 100644 (file)
@@ -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