sensu-go icon indicating copy to clipboard operation
sensu-go copied to clipboard

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

Open amdprophet opened this issue 6 years ago • 6 comments

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.

amdprophet avatar Aug 01 '18 22:08 amdprophet

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
		},
	)

palourde avatar Aug 02 '18 18:08 palourde

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 avatar Feb 08 '20 06:02 calebhailey

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

calebhailey avatar Feb 08 '20 06:02 calebhailey

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] avatar Aug 06 '20 06:08 stale[bot]

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] avatar Feb 10 '21 03:02 stale[bot]

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

amdprophet avatar Nov 04 '21 19:11 amdprophet