From 4a866c13be444795ad30d8f8679bd9773be9cec7 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Fri, 12 Aug 2016 03:23:18 +0200 Subject: [PATCH] Fix ApplyConfig() error handling Currently, Prometheus starts up without any error when there is an invalid rule file :-/ --- cmd/prometheus/main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index c5b9b6435..656ed5fc5 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -227,13 +227,15 @@ func reloadConfig(filename string, rls ...Reloadable) (err error) { return fmt.Errorf("couldn't load configuration (-config.file=%s): %v", filename, err) } - // Apply all configs and return the first error if there were any. + failed := false for _, rl := range rls { - if err != nil { - err = rl.ApplyConfig(conf) - } else { - rl.ApplyConfig(conf) + if err := rl.ApplyConfig(conf); err != nil { + log.Error("Failed to apply configuration: ", err) + failed = true } } - return err + if failed { + return fmt.Errorf("one or more errors occured while applying the new configuration (-config.file=%s)", filename) + } + return nil }