Graylog2 / collector-sidecar

Manage log collectors through Graylog
https://www.graylog.org/
Other
268 stars 56 forks source link

Don't clear configuration when the fetch request fails #427

Closed thll closed 2 years ago

thll commented 2 years ago

When the configuration fetch request failed without an HTTP status code, the sidecar would treat this as a config change and clear its current configuration.

With this change, the failed request won't lead to the invalidation of the current configuration anymore.

Fixes #413

Reproducing this is a bit tricky because the behaviour can only be triggered when the request to /api/sidecar/collectors succeeds, but the subsequent request to /api/sidecar/configurations/render/* fails. I used caddy as a proxy server between the sidecar and the Graylog server to selectively let the latter call fail. This is the Caddyfile I was using:

{
    debug
}

:2016 {

    # alternating every 10 seconds, this will match or not match the configuration fetch request
    @config_fetch {
        path /api/sidecar/configurations/render/*
        expression (int({time.now.unix}) % 20) < 10
    }

    handle @config_fetch {
        abort
    }

    # catch-all
    handle {
        reverse_proxy 127.0.0.1:9000
    }

}

Sidecar is run with the following two settings in sidecar.yml:

server_url: "http://127.0.0.1:2016/api/"
update_interval: 5