Commit 8f7a7224 authored by Geoff Simmons's avatar Geoff Simmons

Update Ingress status.loadBalancer when public viking Service is synced.

Previously the status was only updated when the sync to implement an
Ingress was successful. This will update the status due to changes
in addresses (IPs or hosts) assigned to the Service.
parent 380da817
......@@ -29,6 +29,8 @@
package controller
import (
"reflect"
"code.uplex.de/uplex-varnish/k8s-ingress/pkg/haproxy"
"code.uplex.de/uplex-varnish/k8s-ingress/pkg/update"
"code.uplex.de/uplex-varnish/k8s-ingress/pkg/varnish/vcl"
......@@ -258,6 +260,41 @@ func (worker *NamespaceWorker) syncSvc(key string) update.Status {
return IncompleteIfNotFound(err, "%v", err)
}
// If this Service is labelled as a public viking Service,
// update status.loadBalancer for Ingresses that it
// implements.
if pubSvcVal, exists := svc.Labels[vikingPubSvcKey]; exists &&
pubSvcVal == vikingPubSvcVal {
admSvcs, err := worker.svc.List(varnishIngressSelector)
if err != nil {
if !errors.IsNotFound(err) {
return update.MakeFatal(
"Cannot list admin Services for "+
"public viking Service "+
"%s/%s: %v",
svc.Namespace, svc.Name, err)
}
} else {
for _, admSvc := range admSvcs {
if !worker.isVarnishIngSvc(svc) {
continue
}
if !reflect.DeepEqual(svc.Spec.Selector,
admSvc.Spec.Selector) {
continue
}
ings, status := worker.getIngsForSvc(admSvc)
if status.IsError() {
return status
}
status = worker.updateIngStatus(admSvc, ings)
if status.IsError() {
return status
}
}
}
}
if !worker.isVarnishIngSvc(svc) {
return worker.enqueueIngressForService(svc)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment