Simplify controller interface

This commit is contained in:
Manuel de Brito Fontes 2017-06-11 15:56:30 -04:00
parent ecb95156ca
commit dca6de883c
2 changed files with 10 additions and 23 deletions

View file

@ -153,7 +153,7 @@ func newIngressController(config *Configuration) *GenericController {
cfg: config,
stopLock: &sync.Mutex{},
stopCh: make(chan struct{}),
syncRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.5, 1),
syncRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.3, 1),
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, api.EventSource{
Component: "ingress-controller",
}),
@ -400,27 +400,23 @@ func (ic *GenericController) syncIngress(key interface{}) error {
}
}
data, err := ic.cfg.Backend.OnUpdate(ingress.Configuration{
err := ic.cfg.Backend.OnUpdate(ingress.Configuration{
Backends: upstreams,
Servers: servers,
TCPEndpoints: ic.getStreamServices(ic.cfg.TCPConfigMapName, api.ProtocolTCP),
UDPEndpoints: ic.getStreamServices(ic.cfg.UDPConfigMapName, api.ProtocolUDP),
PassthroughBackends: passUpstreams,
})
if err != nil {
incReloadErrorCount()
glog.Errorf("unexpected failure restarting the backend: \n%v", err)
return err
}
out, reloaded, err := ic.cfg.Backend.Reload(data)
if err != nil {
incReloadErrorCount()
glog.Errorf("unexpected failure restarting the backend: \n%v", string(out))
return err
}
if reloaded {
glog.Infof("ingress backend successfully reloaded...")
incReloadCount()
}
glog.Infof("ingress backend successfully reloaded...")
incReloadCount()
return nil
}

View file

@ -50,14 +50,6 @@ type Controller interface {
// controller status
healthz.HealthzChecker
// Reload takes a byte array representing the new loadbalancer configuration,
// and returns a byte array containing any output/errors from the backend and
// if a reload was required.
// Before returning the backend must load the configuration in the given array
// into the loadbalancer and restart it, or fail with an error and message string.
// If reloading fails, there should be not change in the running configuration or
// the given byte array.
Reload(data []byte) ([]byte, bool, error)
// OnUpdate callback invoked from the sync queue https://k8s.io/ingress/core/blob/master/pkg/ingress/controller/controller.go#L387
// when an update occurs. This is executed frequently because Ingress
// controllers watches changes in:
@ -78,12 +70,11 @@ type Controller interface {
// servers (FQDN) and all the locations inside each server. Each
// location contains information about all the annotations were configured
// https://k8s.io/ingress/core/blob/master/pkg/ingress/types.go#L83
// The backend returns the contents of the configuration file or an error
// with the reason why was not possible to generate the file.
// The backend returns an error if was not possible to update the configuration.
//
// The returned configuration is then passed to test, and then to reload
// if there is no errors.
OnUpdate(Configuration) ([]byte, error)
OnUpdate(Configuration) error
// ConfigMap content of --configmap
SetConfig(*api.ConfigMap)
// SetListers allows the access of store listers present in the generic controller