Skip to content

Commit

Permalink
[remote_v2] return configuration for all available services
Browse files Browse the repository at this point in the history
don't return error status when some services fail, because
they don't have to have working configuration
  • Loading branch information
mikz committed Feb 13, 2017
1 parent b78b01f commit 0c49062
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apicast/src/configuration_loader/remote_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _M:call(environment)
if config then
insert(configs, config)
else
return nil, err
ngx.log(ngx.INFO, 'could not get configuration for service ', object.service.id, ': ', err)
end
end

Expand Down
10 changes: 6 additions & 4 deletions spec/configuration_loader/remote_v2_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Configuration Rmote Loader V2', function()
assert.equal('invalid status', err)
end)

it('does not crash on error when getting config', function()
it('returns configuration even when some services are missing', function()
test_backend.expect{ url = 'http://example.com/admin/api/services.json' }.
respond_with{ status = 200, body = cjson.encode({ services = {
{ service = { id = 1 }},
Expand All @@ -133,10 +133,12 @@ describe('Configuration Rmote Loader V2', function()
test_backend.expect{ url = 'http://example.com/admin/api/services/2/proxy/configs/staging/latest.json' }.
respond_with{ status = 404 }

local config, err = loader:call('staging')
local config = assert(loader:call('staging'))

assert.falsy(config)
assert.equal('invalid status', err)
assert.truthy(config)
assert.equals('string', type(config))

assert.equals(1, #(cjson.decode(config).services))
end)
end)

Expand Down

0 comments on commit 0c49062

Please sign in to comment.