diff --git a/api/graylog.go b/api/graylog.go index bb78baa..d3f7886 100644 --- a/api/graylog.go +++ b/api/graylog.go @@ -42,22 +42,20 @@ var ( ) func GetServerVersion(httpClient *http.Client, ctx *context.Ctx) (*GraylogVersion, error) { - // In case of an error just assume 4.0.0 - fallbackVersion, _ := NewGraylogVersion("4.0.0") - c := rest.NewClient(httpClient, ctx) c.BaseURL = ctx.ServerUrl r, err := c.NewRequest("GET", "/", nil, nil) if err != nil { log.Errorf("Cannot retrieve server version %v", err) - return fallbackVersion, err + return nil, err } versionResponse := graylog.ServerVersionResponse{} resp, err := c.Do(r, &versionResponse) if err != nil || resp == nil { log.Errorf("Error fetching server version %v", err) - return fallbackVersion, err + return nil, err } + log.Debugf("Graylog server version %v", versionResponse.Version) return NewGraylogVersion(versionResponse.Version) } diff --git a/changelog/unreleased/issue-481.toml b/changelog/unreleased/issue-481.toml new file mode 100644 index 0000000..7175242 --- /dev/null +++ b/changelog/unreleased/issue-481.toml @@ -0,0 +1,11 @@ +# PLEASE REMOVE COMMENTS AND OPTIONAL FIELDS! THANKS! + +# Entry type according to https://keepachangelog.com/en/1.0.0/ +# One of: a(dded), c(hanged), d(eprecated), r(emoved), f(ixed), s(ecurity) +type = "fixed" +message = "Avoid stopping collectors if a Graylog cluster behind load balancers is partly shut down." + +issues = ["481"] +pulls = ["482"] + +contributors = [""] diff --git a/services/periodicals.go b/services/periodicals.go index a630cf6..8efa7fb 100644 --- a/services/periodicals.go +++ b/services/periodicals.go @@ -49,7 +49,10 @@ func StartPeriodicals(context *context.Ctx) { } firstRun = false - serverVersion, _ := api.GetServerVersion(httpClient, context) + serverVersion, err := api.GetServerVersion(httpClient, context) + if err != nil { + continue + } // registration regResponse contains configuration assignments regResponse, err := updateCollectorRegistration(httpClient, lastRegResponse.Checksum, context, serverVersion)