Skip to content

Commit

Permalink
Make L4 Controllers' Healthchecks return errors
Browse files Browse the repository at this point in the history
plus minor name fix
  • Loading branch information
cezarygerard committed Mar 22, 2022
1 parent cc29101 commit 4238cc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/l4lb/l4controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func NewILBController(ctx *context.ControllerContext, stopCh chan struct{}) *L4C
})
// TODO enhance this by looking at some metric from service controller to ensure it is up.
// We cannot use existence of a backend service or other resource, since those are on a per-service basis.
ctx.AddHealthCheck("service-controller health", l4c.checkHealth)
ctx.AddHealthCheck("l4-ilb-subsetting-controller", l4c.checkHealth)
return l4c
}

Expand All @@ -144,8 +144,9 @@ func (l4c *L4Controller) checkHealth() error {
syncTimeLatest := lastEnqueueTime.Add(enqueueToSyncDelayThreshold)
if lastSyncTime.After(syncTimeLatest) {
msg := fmt.Sprintf("L4 ILB Sync happened at time %v - %v after enqueue time, threshold is %v", lastSyncTime, lastSyncTime.Sub(lastEnqueueTime), enqueueToSyncDelayThreshold)
// Log here, context/http handler do no log the error.
klog.Error(msg)
// TODO return error here
return fmt.Errorf(msg)
}
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/l4lb/l4netlbcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ func NewL4NetLBController(
}
},
})
//TODO change to component name "l4netlb-controller"
ctx.AddHealthCheck("service-controller health", l4netLBc.checkHealth)
ctx.AddHealthCheck("l4netlb-controller", l4netLBc.checkHealth)
return l4netLBc
}

Expand Down Expand Up @@ -264,7 +263,9 @@ func (lc *L4NetLBController) checkHealth() error {
syncTimeLatest := lastEnqueueTime.Add(enqueueToSyncDelayThreshold)
if lastSyncTime.After(syncTimeLatest) {
msg := fmt.Sprintf("L4 External LoadBalancer Sync happened at time %v - %v after enqueue time, threshold is %v", lastSyncTime, lastSyncTime.Sub(lastEnqueueTime), enqueueToSyncDelayThreshold)
// Log here, context/http handler do no log the error.
klog.Error(msg)
return fmt.Errorf(msg)
}
return nil
}
Expand Down

0 comments on commit 4238cc0

Please sign in to comment.