From b8724ca763a9e8fdd08c22301d4e113eb654c02b Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Thu, 9 Jun 2022 15:11:45 +0200 Subject: [PATCH 1/3] Fix UI build (#10842) Signed-off-by: Julien Pivotto --- web/ui/build_ui.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/ui/build_ui.sh b/web/ui/build_ui.sh index 59ed811366e..d395fc0ecdf 100644 --- a/web/ui/build_ui.sh +++ b/web/ui/build_ui.sh @@ -15,6 +15,10 @@ set -e current=$(pwd) +if ! [[ -w $HOME ]] +then + export npm_config_cache=$(mktemp -d) +fi buildOrder=(module/lezer-promql module/codemirror-promql) From 8ac4e50ec43937aea0e08fc4eb8c7f2f0388e8c0 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Thu, 9 Jun 2022 15:33:31 +0200 Subject: [PATCH 2/3] Add --lint-fatal option (#10815) (#10840) This keeps the previous behaviour of printing details about duplicate rules but doesn't exit with a fatal exit code unless turned on. Signed-off-by: David Leadbeater Co-authored-by: David Leadbeater --- cmd/promtool/main.go | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index 01d953d2049..ad802e48240 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -95,6 +95,9 @@ func main() { "lint", "Linting checks to apply to the rules specified in the config. Available options are: "+strings.Join(lintOptions, ", ")+". Use --lint=none to disable linting", ).Default(lintOptionDuplicateRules).String() + checkConfigLintFatal := checkConfigCmd.Flag( + "lint-fatal", + "Make lint errors exit with exit code 3.").Default("false").Bool() checkWebConfigCmd := checkCmd.Command("web-config", "Check if the web config files are valid or not.") webConfigFiles := checkWebConfigCmd.Arg( @@ -111,6 +114,9 @@ func main() { "lint", "Linting checks to apply. Available options are: "+strings.Join(lintOptions, ", ")+". Use --lint=none to disable linting", ).Default(lintOptionDuplicateRules).String() + checkRulesLintFatal := checkRulesCmd.Flag( + "lint-fatal", + "Make lint errors exit with exit code 3.").Default("false").Bool() checkMetricsCmd := checkCmd.Command("metrics", checkMetricsUsage) checkMetricsExtended := checkCmd.Flag("extended", "Print extended information related to the cardinality of the metrics.").Bool() @@ -236,13 +242,13 @@ func main() { os.Exit(CheckSD(*sdConfigFile, *sdJobName, *sdTimeout)) case checkConfigCmd.FullCommand(): - os.Exit(CheckConfig(*agentMode, *checkConfigSyntaxOnly, newLintConfig(*checkConfigLint), *configFiles...)) + os.Exit(CheckConfig(*agentMode, *checkConfigSyntaxOnly, newLintConfig(*checkConfigLint, *checkConfigLintFatal), *configFiles...)) case checkWebConfigCmd.FullCommand(): os.Exit(CheckWebConfig(*webConfigFiles...)) case checkRulesCmd.FullCommand(): - os.Exit(CheckRules(newLintConfig(*checkRulesLint), *ruleFiles...)) + os.Exit(CheckRules(newLintConfig(*checkRulesLint, *checkRulesLintFatal), *ruleFiles...)) case checkMetricsCmd.FullCommand(): os.Exit(CheckMetrics(*checkMetricsExtended)) @@ -303,11 +309,14 @@ var lintError = fmt.Errorf("lint error") type lintConfig struct { all bool duplicateRules bool + fatal bool } -func newLintConfig(stringVal string) lintConfig { +func newLintConfig(stringVal string, fatal bool) lintConfig { items := strings.Split(stringVal, ",") - ls := lintConfig{} + ls := lintConfig{ + fatal: fatal, + } for _, setting := range items { switch setting { case lintOptionAll: @@ -329,7 +338,7 @@ func (ls lintConfig) lintDuplicateRules() bool { // CheckConfig validates configuration files. func CheckConfig(agentMode, checkSyntaxOnly bool, lintSettings lintConfig, files ...string) int { failed := false - hasLintErrors := false + hasErrors := false for _, f := range files { ruleFiles, err := checkConfig(agentMode, f, checkSyntaxOnly) @@ -352,7 +361,7 @@ func CheckConfig(agentMode, checkSyntaxOnly bool, lintSettings lintConfig, files } failed = true for _, err := range errs { - hasLintErrors = hasLintErrors || errors.Is(err, lintError) + hasErrors = hasErrors || !errors.Is(err, lintError) } } else { fmt.Printf(" SUCCESS: %d rules found\n", n) @@ -360,12 +369,12 @@ func CheckConfig(agentMode, checkSyntaxOnly bool, lintSettings lintConfig, files fmt.Println() } } - if failed && hasLintErrors { - return lintErrExitCode - } - if failed { + if failed && hasErrors { return failureExitCode } + if failed && lintSettings.fatal { + return lintErrExitCode + } return successExitCode } @@ -573,7 +582,7 @@ func checkSDFile(filename string) ([]*targetgroup.Group, error) { // CheckRules validates rule files. func CheckRules(ls lintConfig, files ...string) int { failed := false - hasLintErrors := false + hasErrors := false for _, f := range files { if n, errs := checkRules(f, ls); errs != nil { @@ -583,19 +592,19 @@ func CheckRules(ls lintConfig, files ...string) int { } failed = true for _, err := range errs { - hasLintErrors = hasLintErrors || errors.Is(err, lintError) + hasErrors = hasErrors || !errors.Is(err, lintError) } } else { fmt.Printf(" SUCCESS: %d rules found\n", n) } fmt.Println() } - if failed && hasLintErrors { - return lintErrExitCode - } - if failed { + if failed && hasErrors { return failureExitCode } + if failed && ls.fatal { + return lintErrExitCode + } return successExitCode } From e5b794293fcd879a94b8e26c0c7ec2b45568d95a Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Thu, 9 Jun 2022 16:14:29 +0200 Subject: [PATCH 3/3] Add v2.36.1 CHANGELOG and VERSION update Signed-off-by: Matthias Loibl --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd107d12fe7..9215f67bc7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.36.1 / 2022-06-09 + +* [BUGFIX] promtool: Add --lint-fatal option #10840 + ## 2.36.0 / 2022-05-30 * [FEATURE] Add lowercase and uppercase relabel action. #10641 diff --git a/VERSION b/VERSION index 3a05135cd86..089d1d4e029 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.36.0 +2.36.1