Skip to content

Commit 24dae76

Browse files
cloudnulloilbeater
authored andcommitted
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 1b04dbd commit 24dae76

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

pkg/controller/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func ParseFlags() (*Configuration, error) {
183183
argExternalGatewayVlanID = pflag.Int("external-gateway-vlanid", 0, "The vlanId of port ln-ovn-external, default: 0")
184184
argNodeLocalDNSIP = pflag.String("node-local-dns-ip", "", "Comma-separated string of nodelocal DNS ip addresses")
185185

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

189189
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

+7-5
Original file line numberDiff line numberDiff line change
@@ -1189,11 +1189,13 @@ func (c *Controller) startWorkers(ctx context.Context) {
11891189
c.resyncVpcNatConfig()
11901190
}, time.Second, ctx.Done())
11911191

1192-
go wait.Until(func() {
1193-
if err := c.markAndCleanLSP(); err != nil {
1194-
klog.Errorf("gc lsp error: %v", err)
1195-
}
1196-
}, time.Duration(c.config.GCInterval)*time.Second, ctx.Done())
1192+
if c.config.GCInterval != 0 {
1193+
go wait.Until(func() {
1194+
if err := c.markAndCleanLSP(); err != nil {
1195+
klog.Errorf("gc lsp error: %v", err)
1196+
}
1197+
}, time.Duration(c.config.GCInterval)*time.Second, ctx.Done())
1198+
}
11971199

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

pkg/controller/gc.go

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import (
2525
var lastNoPodLSP = strset.New()
2626

2727
func (c *Controller) gc() error {
28+
if c.config.GCInterval == 0 {
29+
klog.Infof("gc is disabled")
30+
return nil
31+
}
2832
gcFunctions := []func() error{
2933
c.gcNode,
3034
c.gcChassis,

0 commit comments

Comments
 (0)