Skip to content

Commit

Permalink
Send heartbeats during NetworkPolicy and NetworkService sync.
Browse files Browse the repository at this point in the history
In reference to issue cloudnativelabs#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 <[email protected]>
  • Loading branch information
danboucher78 authored and ticpu committed May 31, 2019
1 parent 6470795 commit 07f80ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controllers/netpol/network_policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type NetworkPolicyController struct {
MetricsEnabled bool
v1NetworkPolicy bool
readyForUpdates bool
healthChan chan<- *healthcheck.ControllerHeartbeat

// list of all active network policies expressed as networkPolicyInfo
networkPoliciesInfo *[]networkPolicyInfo
Expand Down Expand Up @@ -140,6 +141,7 @@ func (npc *NetworkPolicyController) Run(healthChan chan<- *healthcheck.Controlle
defer wg.Done()

glog.Info("Starting network policy controller")
npc.healthChan = healthChan

// loop forever till notified to stop on stopCh
for {
Expand Down Expand Up @@ -222,6 +224,7 @@ func (npc *NetworkPolicyController) Sync() error {
npc.mu.Lock()
defer npc.mu.Unlock()

healthcheck.SendHeartBeat(npc.healthChan, "NPC")
start := time.Now()
syncVersion := strconv.FormatInt(start.UnixNano(), 10)
defer func() {
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control

case <-t.C:
glog.V(1).Info("Performing periodic sync of ipvs services")
healthcheck.SendHeartBeat(healthChan, "NSC")
err := nsc.doSync()
if err != nil {
glog.Errorf("Error during periodic ipvs sync in network service controller. Error: " + err.Error())
Expand Down

0 comments on commit 07f80ec

Please sign in to comment.