Send heartbeats during NetworkPolicy and NetworkService sync. (#741)

In reference to issue #725, we modified kube-router to send
heartbeats before starting policy sync to prevent missing
heartbeats while running iptables commands.

Signed-off-by: Jérôme Poulin <jeromepoulin@gmail.com>
This commit is contained in:
Jérôme Poulin 2019-06-24 07:33:03 -04:00 committed by Murali Reddy
parent 6470795db3
commit 94fd7b6d74
2 changed files with 4 additions and 0 deletions

View File

@ -58,6 +58,7 @@ type NetworkPolicyController struct {
MetricsEnabled bool MetricsEnabled bool
v1NetworkPolicy bool v1NetworkPolicy bool
readyForUpdates bool readyForUpdates bool
healthChan chan<- *healthcheck.ControllerHeartbeat
// list of all active network policies expressed as networkPolicyInfo // list of all active network policies expressed as networkPolicyInfo
networkPoliciesInfo *[]networkPolicyInfo networkPoliciesInfo *[]networkPolicyInfo
@ -140,6 +141,7 @@ func (npc *NetworkPolicyController) Run(healthChan chan<- *healthcheck.Controlle
defer wg.Done() defer wg.Done()
glog.Info("Starting network policy controller") glog.Info("Starting network policy controller")
npc.healthChan = healthChan
// loop forever till notified to stop on stopCh // loop forever till notified to stop on stopCh
for { for {
@ -222,6 +224,7 @@ func (npc *NetworkPolicyController) Sync() error {
npc.mu.Lock() npc.mu.Lock()
defer npc.mu.Unlock() defer npc.mu.Unlock()
healthcheck.SendHeartBeat(npc.healthChan, "NPC")
start := time.Now() start := time.Now()
syncVersion := strconv.FormatInt(start.UnixNano(), 10) syncVersion := strconv.FormatInt(start.UnixNano(), 10)
defer func() { defer func() {

View File

@ -384,6 +384,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
case <-t.C: case <-t.C:
glog.V(1).Info("Performing periodic sync of ipvs services") glog.V(1).Info("Performing periodic sync of ipvs services")
healthcheck.SendHeartBeat(healthChan, "NSC")
err := nsc.doSync() err := nsc.doSync()
if err != nil { if err != nil {
glog.Errorf("Error during periodic ipvs sync in network service controller. Error: " + err.Error()) glog.Errorf("Error during periodic ipvs sync in network service controller. Error: " + err.Error())