Skip to content

Commit 94fd7b6

Browse files
ticpumurali-reddy
authored andcommitted
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 <[email protected]>
1 parent 6470795 commit 94fd7b6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

pkg/controllers/netpol/network_policy_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type NetworkPolicyController struct {
5858
MetricsEnabled bool
5959
v1NetworkPolicy bool
6060
readyForUpdates bool
61+
healthChan chan<- *healthcheck.ControllerHeartbeat
6162

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

142143
glog.Info("Starting network policy controller")
144+
npc.healthChan = healthChan
143145

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

227+
healthcheck.SendHeartBeat(npc.healthChan, "NPC")
225228
start := time.Now()
226229
syncVersion := strconv.FormatInt(start.UnixNano(), 10)
227230
defer func() {

pkg/controllers/proxy/network_services_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
384384

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

0 commit comments

Comments
 (0)