Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs: disable invalid warning when no api_backend #1285

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bump Openresty version to 1.19.3 [PR #1272](https://github.com/3scale/APIcast/pull/1272) [THREESCALE-6963](https://issues.redhat.com/browse/THREESCALE-6963)
- Change how ngx.encode_args is made on usage [PR #1277](https://github.com/3scale/APIcast/pull/1277) [THREESCALE-7122](https://issues.redhat.com/browse/THREESCALE-7122)
- Upstream pool key when is using HTTPs connection [PR #1274](https://github.com/3scale/APIcast/pull/1274) [THREESCALE-6849](https://issues.redhat.com/browse/THREESCALE-6849)
- Fix a warning message on invalid upstream [PR #1285](https://github.com/3scale/APIcast/pull/1285) [THREESCALE-5225](https://issues.redhat.com/browse/THREESCALE-5225)
- Upstream MTLS server verify [PR #1280](https://github.com/3scale/APIcast/pull/1280) [THREESCALE-7099](https://issues.redhat.com/browse/THREESCALE-7099)


Expand Down
7 changes: 7 additions & 0 deletions gateway/src/apicast/proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ function _M.get_upstream(service, context)
if not service then
return errors.service_not_found()
end

-- Due to API as a product, the api_backend is no longer needed because this
-- can be handled by routing policy
if not service.api_backend then
return nil, nil
end

local upstream, err = Upstream.new(service.api_backend)
if not upstream then
return nil, err
Expand Down
13 changes: 13 additions & 0 deletions spec/proxy_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ describe('Proxy', function()
assert.same(80, get_upstream({ api_backend = 'http://example.com' }):port())
assert.same(8080, get_upstream({ api_backend = 'http://example.com:8080' }):port())
end)

it("on invalid api_backend return error", function()
local upstream, err = get_upstream({ api_backend = 'test.com' })
assert.falsy(upstream)
assert.same(err, "invalid upstream")
end)

it("on no api_backend return nil and no error", function()
local upstream, err = get_upstream({})
assert.falsy(upstream)
assert.falsy(err)
end)

end)

describe('.authorize', function()
Expand Down