Skip to content

Commit fc8a8fe

Browse files
authored
Merge pull request #4291 from twz123/keepalied-debug
Enable console logging for keepalived
2 parents 66b144c + 856126b commit fc8a8fe

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

cmd/controller/controller.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ func (c *command) start(ctx context.Context) error {
231231
enableCPLB := !c.SingleNode && !slices.Contains(c.DisableComponents, constant.CPLBComponentName)
232232
if enableCPLB {
233233
nodeComponents.Add(ctx, &controller.Keepalived{
234-
K0sVars: c.K0sVars,
235-
Config: nodeConfig.Spec.Network.ControlPlaneLoadBalancing,
234+
K0sVars: c.K0sVars,
235+
Config: nodeConfig.Spec.Network.ControlPlaneLoadBalancing,
236+
DetailedLogging: c.Debug,
236237
})
237238
}
238239

pkg/component/controller/cplb_unix.go

+19-10
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ import (
4242

4343
// Keepalived is the controller for the keepalived process in the control plane load balancing
4444
type Keepalived struct {
45-
K0sVars *config.CfgVars
46-
Config *k0sAPI.ControlPlaneLoadBalancingSpec
47-
uid int
48-
supervisor *supervisor.Supervisor
49-
log *logrus.Entry
45+
K0sVars *config.CfgVars
46+
Config *k0sAPI.ControlPlaneLoadBalancingSpec
47+
DetailedLogging bool
48+
uid int
49+
supervisor *supervisor.Supervisor
50+
log *logrus.Entry
5051
}
5152

5253
// Init extracts the needed binaries and creates the directories
@@ -92,15 +93,23 @@ func (k *Keepalived) Start(_ context.Context) error {
9293

9394
}
9495

96+
args := []string{
97+
"--dont-fork",
98+
"--use-file",
99+
k.K0sVars.KeepalivedConfigFile,
100+
"--no-syslog",
101+
"--log-console",
102+
}
103+
104+
if k.DetailedLogging {
105+
args = append(args, "--log-detail")
106+
}
107+
95108
k.log.Infoln("Starting keepalived")
96109
k.supervisor = &supervisor.Supervisor{
97110
Name: "keepalived",
98111
BinPath: assets.BinPath("keepalived", k.K0sVars.BinDir),
99-
Args: []string{
100-
"--dont-fork",
101-
"--use-file",
102-
k.K0sVars.KeepalivedConfigFile,
103-
},
112+
Args: args,
104113
RunDir: filepath.Dir(k.K0sVars.KeepalivedConfigFile),
105114
DataDir: filepath.Dir(k.K0sVars.KeepalivedConfigFile),
106115
UID: k.uid,

pkg/component/controller/cplb_windows.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
// Keepalived doesn't work on windows, so we cannot implement it at all.
2828
// Just create the interface so that the CI doesn't complain.
2929
type Keepalived struct {
30-
K0sVars *config.CfgVars
31-
Config *k0sAPI.ControlPlaneLoadBalancingSpec
30+
K0sVars *config.CfgVars
31+
Config *k0sAPI.ControlPlaneLoadBalancingSpec
32+
DetailedLogging bool
3233
}
3334

3435
func (k *Keepalived) Init(_ context.Context) error {

0 commit comments

Comments
 (0)