Skip to content

Commit

Permalink
Merge pull request #3367 from aledbf/503-restart
Browse files Browse the repository at this point in the history
Remove reloads when there is no endpoints
  • Loading branch information
k8s-ci-robot authored Nov 6, 2018
2 parents d53b492 + 3838145 commit 08d5ffa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 7 additions & 11 deletions internal/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions rootfs/etc/nginx/lua/balancer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 08d5ffa

Please sign in to comment.