Fix passing arguments to k3s agent and k0s worker (#686)

Signed-off-by: Mauro Morales <contact@mauromorales.com>
This commit is contained in:
Mauro Morales 2025-01-27 16:35:21 +01:00 committed by GitHub
parent 809f00343c
commit d74f5c86b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,7 +165,7 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
l.Info("One time bootstrap starting")
var svc machine.Service
var svcName, svcRole, envFile, binPath string
var svcName, svcRole, envFile, binPath, args string
var svcEnv map[string]string
if !c.IsAKubernetesDistributionEnabled() {
@ -177,24 +177,28 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
svcName = "k3s-agent"
svcRole = "agent"
svcEnv = c.K3sAgent.Env
args = strings.Join(c.K3sAgent.Args, " ")
}
if c.IsK3sEnabled() {
svcName = "k3s"
svcRole = "server"
svcEnv = c.K3s.Env
args = strings.Join(c.K3s.Args, " ")
}
if c.IsK0sEnabled() {
svcName = "k0scontroller"
svcRole = "controller"
svcEnv = c.K0s.Env
args = strings.Join(c.K0s.Args, " ")
}
if c.IsK0sWorkerEnabled() {
svcName = "k0sworker"
svcRole = "worker"
svcEnv = c.K0sWorker.Env
args = strings.Join(c.K0sWorker.Args, " ")
}
if c.IsK3sDistributionEnabled() {
@ -232,14 +236,6 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
return fmt.Errorf("could not detect OS")
}
// Args can come from k3s or k0s
var args string
if c.IsK3sDistributionEnabled() {
args = strings.Join(c.K3s.Args, " ")
} else if c.IsK0sDistributionEnabled() {
args = strings.Join(c.K0s.Args, " ")
}
// Override the service command and start it
if err := svc.OverrideCmd(fmt.Sprintf("%s %s %s", binPath, svcRole, args)); err != nil {
l.Errorf("Failed to override service command: %s", err.Error())