Skip to content

Commit

Permalink
Merge pull request #2852 from Shopify/fix-2513
Browse files Browse the repository at this point in the history
fix custom-error-pages functionality in dynamic mode
  • Loading branch information
k8s-ci-robot authored Jul 26, 2018
2 parents e89c569 + a2692ce commit d263577
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/ingress/controller/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func TestConfigureDynamically(t *testing.T) {
t.Errorf("unexpected target reference in JSON content: %v", body)
}

if strings.Contains(body, "service") {
t.Errorf("unexpected service reference in JSON content: %v", body)
if !strings.Contains(body, "service") {
t.Errorf("service reference should be present in JSON content: %v", body)
}

}))
Expand Down
11 changes: 8 additions & 3 deletions rootfs/etc/nginx/lua/util/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ end
function _M.resolve(host)
local cached_addresses = cache:get(host)
if cached_addresses then
ngx.log(ngx.INFO, string.format("addresses %s for host %s was resolved from cache", table.concat(cached_addresses, ", "), host))
local message = string.format(
"addresses %s for host %s was resolved from cache",
table.concat(cached_addresses, ", "), host)
ngx.log(ngx.INFO, message)
return cached_addresses
end

local r, err = resolver:new{
local r
r, err = resolver:new{
nameservers = util.deepcopy(configuration.nameservers),
retrans = 5,
timeout = 2000, -- 2 sec
Expand All @@ -46,7 +50,8 @@ function _M.resolve(host)
return { host }
end

local answers, err, _tries = r:query(host, { qtype = r.TYPE_A }, {})
local answers
answers, err = r:query(host, { qtype = r.TYPE_A }, {})
if not answers then
ngx.log(ngx.ERR, "failed to query the DNS server: " .. tostring(err))
return { host }
Expand Down
2 changes: 2 additions & 0 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ stream {
proxy_set_header X-Service-Name $service_name;
proxy_set_header X-Service-Port $service_port;

set $proxy_upstream_name "upstream-default-backend";

rewrite (.*) / break;

{{ if $dynamicConfig }}
Expand Down

0 comments on commit d263577

Please sign in to comment.