Skip to content

Commit

Permalink
fix: ignore kernel command line in container mode
Browse files Browse the repository at this point in the history
Ignore kernel command line for `SideroLink` and `EventsSink` config when
running in container mode. Otherwise when running Talos as a docker
container in Talos it picks up the host kernel cmdline and try to
configure SideroLink/EventsSink.

Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
frezbo committed Nov 21, 2023
1 parent 020a0eb commit aca8b5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import (
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"

v1alpha1runtime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/resources/config"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

// EventsSinkConfigController generates configuration for kmsg log delivery.
type EventsSinkConfigController struct {
Cmdline *procfs.Cmdline
Cmdline *procfs.Cmdline
V1Alpha1Mode v1alpha1runtime.Mode
}

// Name implements controller.Controller interface.
Expand Down Expand Up @@ -65,7 +67,7 @@ func (ctrl *EventsSinkConfigController) Run(ctx context.Context, r controller.Ru

var endpoint string

if ctrl.Cmdline != nil {
if ctrl.Cmdline != nil && ctrl.V1Alpha1Mode != v1alpha1runtime.ModeContainer {
if val := ctrl.Cmdline.Get(constants.KernelParamEventsSink).First(); val != nil {
endpoint = *val
}
Expand Down
8 changes: 7 additions & 1 deletion internal/app/machined/pkg/controllers/siderolink/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import (
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"

v1alpha1runtime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/resources/config"
"github.com/siderolabs/talos/pkg/machinery/resources/siderolink"
)

// ConfigController interacts with SideroLink API and brings up the SideroLink Wireguard interface.
type ConfigController struct {
Cmdline *procfs.Cmdline
Cmdline *procfs.Cmdline
V1Alpha1Mode v1alpha1runtime.Mode
}

// Name implements controller.Controller interface.
Expand Down Expand Up @@ -89,6 +91,10 @@ func (ctrl *ConfigController) apiEndpoint(machineConfig *config.MachineConfig) s
return machineConfig.Config().SideroLink().APIUrl().String()
}

if ctrl.V1Alpha1Mode == v1alpha1runtime.ModeContainer {
return ""
}

if ctrl.Cmdline == nil || ctrl.Cmdline.Get(constants.KernelParamSideroLink).First() == nil {
return ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ func (ctrl *Controller) Run(ctx context.Context, drainer *runtime.Drainer) error
MetaProvider: ctrl.v1alpha1Runtime.State().Machine(),
},
&runtimecontrollers.EventsSinkConfigController{
Cmdline: procfs.ProcCmdline(),
Cmdline: procfs.ProcCmdline(),
V1Alpha1Mode: ctrl.v1alpha1Runtime.State().Platform().Mode(),
},
&runtimecontrollers.EventsSinkController{
V1Alpha1Events: ctrl.v1alpha1Runtime.Events(),
Expand Down Expand Up @@ -297,7 +298,8 @@ func (ctrl *Controller) Run(ctx context.Context, drainer *runtime.Drainer) error
secrets.NewRootOSController(),
&secrets.TrustdController{},
&siderolink.ConfigController{
Cmdline: procfs.ProcCmdline(),
Cmdline: procfs.ProcCmdline(),
V1Alpha1Mode: ctrl.v1alpha1Runtime.State().Platform().Mode(),
},
&siderolink.ManagerController{},
&timecontrollers.AdjtimeStatusController{
Expand Down

0 comments on commit aca8b5e

Please sign in to comment.