diff --git a/pkg/controller/keepalived.go b/pkg/controller/keepalived.go index e8db4c9d..5acfadd9 100644 --- a/pkg/controller/keepalived.go +++ b/pkg/controller/keepalived.go @@ -76,7 +76,7 @@ func (k *keepalived) WriteCfg(svcs []vip) error { conf["myIP"] = k.ip conf["netmask"] = k.netmask conf["svcs"] = svcs - conf["vips"] = getVIPs(svcs) + conf["vips"] = k.vips conf["nodes"] = k.neighbors conf["priority"] = k.priority conf["useUnicast"] = k.useUnicast @@ -165,6 +165,7 @@ func (k *keepalived) Reload() error { return nil } + k.Cleanup() glog.Info("reloading keepalived") err := syscall.Kill(k.cmd.Process.Pid, syscall.SIGHUP) if err != nil { @@ -174,8 +175,8 @@ func (k *keepalived) Reload() error { return nil } -// Stop stop keepalived process -func (k *keepalived) Stop() { +func (k *keepalived) Cleanup() { + glog.Infof("Cleanup: %s", k.vips) for _, vip := range k.vips { k.removeVIP(vip) } @@ -184,20 +185,24 @@ func (k *keepalived) Stop() { if err != nil { glog.V(2).Infof("unexpected error flushing iptables chain %v: %v", err, iptablesChain) } +} - err = syscall.Kill(k.cmd.Process.Pid, syscall.SIGTERM) +// Stop stop keepalived process +func (k *keepalived) Stop() { + k.Cleanup() + + err := syscall.Kill(k.cmd.Process.Pid, syscall.SIGTERM) if err != nil { glog.Errorf("error stopping keepalived: %v", err) } } -func (k *keepalived) removeVIP(vip string) error { +func (k *keepalived) removeVIP(vip string) { glog.Infof("removing configured VIP %v", vip) out, err := k8sexec.New().Command("ip", "addr", "del", vip+"/32", "dev", k.iface).CombinedOutput() if err != nil { - return fmt.Errorf("error reloading keepalived: %v\n%s", err, out) + glog.V(2).Infof("Error removing VIP %s: %v\n%s", vip, err, out) } - return nil } func (k *keepalived) loadTemplates() error { diff --git a/pkg/controller/main.go b/pkg/controller/main.go index 1f5edb3b..12952756 100644 --- a/pkg/controller/main.go +++ b/pkg/controller/main.go @@ -123,6 +123,7 @@ type ipvsControllerController struct { keepalived *keepalived configMapName string + configMapResourceVersion string ruMD5 string @@ -259,6 +260,12 @@ func (ipvsc *ipvsControllerController) sync(key interface{}) error { return fmt.Errorf("unexpected error searching configmap %v: %v", ipvsc.configMapName, err) } + if ipvsc.configMapResourceVersion == cfgMap.ObjectMeta.ResourceVersion { + glog.V(2).Infof("No change to %s ConfigMap", name) + return nil + } + + ipvsc.configMapResourceVersion = cfgMap.ObjectMeta.ResourceVersion svc := ipvsc.getServices(cfgMap) err = ipvsc.keepalived.WriteCfg(svc) diff --git a/rootfs/Dockerfile b/rootfs/Dockerfile index 88ff4989..12c7faeb 100644 --- a/rootfs/Dockerfile +++ b/rootfs/Dockerfile @@ -23,7 +23,7 @@ RUN clean-install \ libxtables12 \ libnfnetlink0 \ libiptcdata0 \ - libipset3 \ + libipset11 \ libipset-dev \ libsnmp30 \ kmod \