diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 5739f805b..1533de78c 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -423,15 +423,14 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([] aUpstreams := make([]*ingress.Backend, 0, len(upstreams)) for _, upstream := range upstreams { + aUpstreams = append(aUpstreams, upstream) + isHTTPSfrom := []*ingress.Server{} for _, server := range servers { for _, location := range server.Locations { if upstream.Name == location.Backend { if len(upstream.Endpoints) == 0 { glog.V(3).Infof("Upstream %q has no active Endpoint", upstream.Name) - - location.Backend = "" // for nginx.tmpl checking - // check if the location contains endpoints and a custom default backend if location.DefaultBackend != nil { sp := location.DefaultBackend.Spec.Ports[0] @@ -468,14 +467,6 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([] } } - // create the list of upstreams and skip those without Endpoints - for _, upstream := range upstreams { - if len(upstream.Endpoints) == 0 { - continue - } - aUpstreams = append(aUpstreams, upstream) - } - aServers := make([]*ingress.Server, 0, len(servers)) for _, value := range servers { sort.SliceStable(value.Locations, func(i, j int) bool { @@ -552,6 +543,11 @@ func (n *NGINXController) createUpstreams(data []*extensions.Ingress, du *ingres } } + s, err := n.store.GetService(svcKey) + if err != nil { + glog.Warningf("Error obtaining Service %q: %v", svcKey, err) + } + upstreams[defBackend].Service = s } for _, rule := range ing.Spec.Rules { diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index 7fd58a39c..cefa86373 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -68,6 +68,11 @@ local function format_ipv6_endpoints(endpoints) end local function sync_backend(backend) + if not backend.endpoints or #backend.endpoints == 0 then + ngx.log(ngx.INFO, string.format("there is no endpoint for backend %s. Skipping...", backend.name)) + return + end + local implementation = get_implementation(backend) local balancer = balancers[backend.name]