sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.01k stars 177 forks source link

Allow more than one backend-url to be specified in sensuctl #1907

Open amdprophet opened 6 years ago

amdprophet commented 6 years ago

Allow more than one backend-url to be specified in sensuctl for fail-over purposes.

Expected Behavior

A user should be able to specify more than one backend and have sensuctl pick one (either sequentially or at random). If sensuctl cannot communicate with the chosen backend, attempt to talk to a different backend.

Current Behavior

Only one backend-url can be specified.

palourde commented 6 years ago

FYI, I made a quick PoC to figure out how we could achieve that.

First, we'll need to refactor the Cluster config to support one or multiple APIUrl while staying backward compatible: https://github.com/sensu/sensu-go/blob/2a7f0d799a2c2ef539bab7261ac229b9d9ad3cef/cli/client/config/basic/basic.go#L32-L36

Then, we just need to play with Resty to add retries (https://github.com/go-resty/resty#retries). It would look something like this in the New function:

    restyInst.SetRetryCount(2)
    restyInst.AddRetryCondition(
        func(r *resty.Response) (bool, error) {
            // Switch the HostURL to an another backend API. We need to have some
            // logic to exclude the one that just failed. Maybe inspect r.StatusCode()
            // too to ensure it's a connection error and not a 401 or 404 etc.
            restyInst.SetHostURL("http://127.0.0.1:9080")
            return true, nil
        },
    )
calebhailey commented 4 years ago

Closing due to inactivity (this issue was created pre-GA), plus it looks like this has been resolved & documented. It is now possible to set multiple backend URLs by setting the --backend-url flag multiple times.

See: https://docs.sensu.io/sensu-go/latest/reference/agent/#configuration

calebhailey commented 4 years ago

Oops, I misread this as "sensu-agent". This is RE: sensuctl which may still be a valid issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

amdprophet commented 2 years ago

With a new major version we can remove the api-url field and replace it with api-urls.