Skip to content

Commit

Permalink
Merge pull request #74 from backguynn/main
Browse files Browse the repository at this point in the history
Delete the lb rule only when the SIGTERM signal is received.
  • Loading branch information
UltraInstinct14 authored Nov 21, 2023
2 parents 7467b0c + 7739e4f commit 60be850
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/loxilb-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
// https://github.com/kubernetes/kubernetes/blob/release-1.17/pkg/controller/apis/config/v1alpha1/defaults.go#L120
const informerDefaultResync = 12 * time.Hour

var closeSig os.Signal
var (
capturedSignals = []os.Signal{syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT}
notifyCh = make(chan os.Signal, 2)
Expand Down Expand Up @@ -195,7 +196,10 @@ func run(o *Options) error {

<-stopCh

lbManager.DeleteAllLoadBalancer()
if closeSig == syscall.SIGTERM {
klog.Info("flushing LoxiLB rules")
lbManager.DeleteAllLoadBalancer()
}

klog.Info("Stopping loxilb Agent")
return nil
Expand All @@ -205,7 +209,7 @@ func RegisterSignalHandlers() <-chan struct{} {
stopCh := make(chan struct{})

go func() {
<-notifyCh
closeSig = <-notifyCh
close(stopCh)
<-notifyCh
klog.Warning("Received second signal, will force exit")
Expand Down

0 comments on commit 60be850

Please sign in to comment.