mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FEATURE: Allow a cluster_name to be configured and used for /srv/status (#12365)
The cluster name can be configured by setting the `DISCOURSE_CLUSTER_NAME` environment variable. If set, you can then call /srv/status with a `?cluster=` parameter. If the cluster does not match, an error will be returned. This is useful if you need a load balancer to be able to verify the identity, as well as the presence, of an application container.
This commit is contained in:
@ -37,4 +37,31 @@ RSpec.describe ForumsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "cluster parameter" do
|
||||
it "returns a 500 response if the cluster is not configured" do
|
||||
get "/srv/status?cluster=abc"
|
||||
expect(response.status).to eq(500)
|
||||
expect(response.body).to include("not configured")
|
||||
end
|
||||
|
||||
it "returns a 500 response if the cluster does not match" do
|
||||
global_setting(:cluster_name, "mycluster")
|
||||
get "/srv/status?cluster=abc"
|
||||
expect(response.status).to eq(500)
|
||||
expect(response.body).to include("not match")
|
||||
end
|
||||
|
||||
it "returns a 200 response if the cluster does match" do
|
||||
global_setting(:cluster_name, "mycluster")
|
||||
get "/srv/status?cluster=abc"
|
||||
expect(response.status).to eq(500)
|
||||
expect(response.body).to include("not match")
|
||||
end
|
||||
|
||||
it "returns a 200 response when given shutdown_ok" do
|
||||
get "/srv/status?shutdown_ok=1"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user