Skip to content

Commit 4005606

Browse files
authored
feat(GC): Add check for GC disabled (#5005)
This change implements a simple check, if the GCInterval is set to the GC methods will not run, even on server start. This change allows an operator to run kube-ovn in mixed environments without worry that garbage collection would inadvertently destroy something it shouldn't. Related-Issue: #4995 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
1 parent 87feaf5 commit 4005606

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

pkg/controller/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func ParseFlags() (*Configuration, error) {
186186
argExternalGatewayVlanID = pflag.Int("external-gateway-vlanid", 0, "The vlanId of port ln-ovn-external, default: 0")
187187
argNodeLocalDNSIP = pflag.String("node-local-dns-ip", "", "Comma-separated string of nodelocal DNS ip addresses")
188188

189-
argGCInterval = pflag.Int("gc-interval", 360, "The interval between GC processes, default 360 seconds")
189+
argGCInterval = pflag.Int("gc-interval", 360, "The interval between GC processes, default 360 seconds. If set to 0, GC will be disabled")
190190
argInspectInterval = pflag.Int("inspect-interval", 20, "The interval between inspect processes, default 20 seconds")
191191

192192
argBfdMinTx = pflag.Int("bfd-min-tx", 100, "This is the minimum interval, in milliseconds, ovn would like to use when transmitting BFD Control packets")

pkg/controller/controller.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,13 @@ func (c *Controller) startWorkers(ctx context.Context) {
12431243
c.resyncVpcNatConfig()
12441244
}, time.Second, ctx.Done())
12451245

1246-
go wait.Until(func() {
1247-
if err := c.markAndCleanLSP(); err != nil {
1248-
klog.Errorf("gc lsp error: %v", err)
1249-
}
1250-
}, time.Duration(c.config.GCInterval)*time.Second, ctx.Done())
1246+
if c.config.GCInterval != 0 {
1247+
go wait.Until(func() {
1248+
if err := c.markAndCleanLSP(); err != nil {
1249+
klog.Errorf("gc lsp error: %v", err)
1250+
}
1251+
}, time.Duration(c.config.GCInterval)*time.Second, ctx.Done())
1252+
}
12511253

12521254
go wait.Until(func() {
12531255
if err := c.inspectPod(); err != nil {

pkg/controller/gc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import (
2828
var lastNoPodLSP = strset.New()
2929

3030
func (c *Controller) gc() error {
31+
if c.config.GCInterval == 0 {
32+
klog.Infof("gc is disabled")
33+
return nil
34+
}
3135
gcFunctions := []func() error{
3236
c.gcNode,
3337
c.gcChassis,

0 commit comments

Comments
 (0)