Set haproxy state to up when got 401 error
Haproxy state should be set to up, when got 401 code from client
side - Unauthorized - that means that backend is ready and up.
Change-Id: I65b6e6789ac376a2ba0c95f03f6963fed804ba2d
Closes-bug: #1597416
(cherry picked from commit 7e4afb7a6f
)
This commit is contained in:
parent
e283b62750
commit
6d782f6c0a
@ -20,7 +20,7 @@ Puppet::Type.type(:haproxy_backend_status).provide(:http) do
|
||||
status = get_url
|
||||
return :absent unless status
|
||||
return :present if [:present, :absent].include? @resource[:ensure]
|
||||
return :up if status.kind_of? Net::HTTPSuccess or status.kind_of? Net::HTTPRedirection
|
||||
return :up if status.kind_of? Net::HTTPSuccess or status.kind_of? Net::HTTPRedirection or status.kind_of? Net::HTTPUnauthorized
|
||||
return :down if status.kind_of? Net::HTTPServerError or status.kind_of? Net::HTTPClientError
|
||||
:present
|
||||
end
|
||||
|
@ -29,6 +29,10 @@ describe Puppet::Type.type(:haproxy_backend_status).provider(:http) do
|
||||
Net::HTTPFound.new('1.1', '302', 'Found')
|
||||
end
|
||||
|
||||
let (:http_401) do
|
||||
Net::HTTPFound.new('1.1', '401', 'Unauthorized')
|
||||
end
|
||||
|
||||
let (:http_503) do
|
||||
Net::HTTPServiceUnavailable.new('1.1', '503', 'Service Unavailable')
|
||||
end
|
||||
@ -81,4 +85,9 @@ describe Puppet::Type.type(:haproxy_backend_status).provider(:http) do
|
||||
expect(provider.ensure).to eq(:absent)
|
||||
end
|
||||
|
||||
it 'should return :up for running backend (HTTP 401)' do
|
||||
resource[:name] = 'test-up'
|
||||
provider.stubs(:get_url).returns(http_401)
|
||||
expect(provider.ensure).to eq(:up)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user