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

Remove reloads when there is no endpoints #3367

Merged
merged 1 commit into from
Nov 6, 2018
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
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