Skip to content

Commit

Permalink
add switch for compact (#3336)
Browse files Browse the repository at this point in the history
* add switch for compact
  • Loading branch information
changluyi committed Oct 25, 2023
1 parent 1fe0a99 commit 49061ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion dist/images/start-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ cat /proc/cmdline"
exit 1
fi

PRBOE_INTERVAL=${PRBOE_INTERVAL:-5}
ENABLE_COMPACT=${ENABLE_COMPACT:-false}
DB_NB_ADDR=${DB_NB_ADDR:-::}
DB_NB_PORT=${DB_NB_PORT:-6641}
DB_SB_ADDR=${DB_SB_ADDR:-::}
Expand Down Expand Up @@ -366,5 +368,5 @@ ovs-appctl -t /var/run/ovn/ovnnb_db.ctl ovsdb-server/memory-trim-on-compaction o
ovs-appctl -t /var/run/ovn/ovnsb_db.ctl ovsdb-server/memory-trim-on-compaction on

chmod 600 /etc/ovn/*
/kube-ovn/kube-ovn-leader-checker
/kube-ovn/kube-ovn-leader-checker --probeInterval=$PRBOE_INTERVAL --enableCompact=$ENABLE_COMPACT

10 changes: 8 additions & 2 deletions pkg/ovn_leader_checker/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Configuration struct {
KubeConfigFile string
KubeClient kubernetes.Interface
ProbeInterval int
EnableCompact bool
}

// ParseFlags parses cmd args then init kubeclient and conf
Expand All @@ -51,6 +52,7 @@ func ParseFlags() (*Configuration, error) {
var (
argKubeConfigFile = pflag.String("kubeconfig", "", "Path to kubeconfig file with authorization and master location information. If not set use the inCluster token.")
argProbeInterval = pflag.Int("probeInterval", DefaultProbeInterval, "interval of probing leader in seconds")
argEnableCompact = pflag.Bool("enableCompact", true, "is enable compact")
)

klogFlags := flag.NewFlagSet("klog", flag.ContinueOnError)
Expand Down Expand Up @@ -80,6 +82,7 @@ func ParseFlags() (*Configuration, error) {
config := &Configuration{
KubeConfigFile: *argKubeConfigFile,
ProbeInterval: *argProbeInterval,
EnableCompact: *argEnableCompact,
}
return config, nil
}
Expand Down Expand Up @@ -379,8 +382,11 @@ func doOvnLeaderCheck(cfg *Configuration, podName string, podNamespace string) {
stealLock()
}
}
compactOvnDatabase("nb")
compactOvnDatabase("sb")

if cfg.EnableCompact {
compactOvnDatabase("nb")
compactOvnDatabase("sb")
}
}

func StartOvnLeaderCheck(cfg *Configuration) {
Expand Down

0 comments on commit 49061ce

Please sign in to comment.