From 51f488fbc3a379067ed9e28c9e22aec079baf7e9 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 14 Dec 2020 17:03:09 +0300 Subject: [PATCH] fix: overwrite kernel args from --extra-agent-kernel-args This allows to override default options (e.g. `console=ttyS0`) with provided values. Make sure that full value is given for each option, as any default values for the option are dropped if specified in `--extra-agent-kernel-args`, e.g. `--extra-agent-kernel-args=console=ttyS1`. Fixes #251 Signed-off-by: Andrey Smirnov --- .../internal/ipxe/ipxe_server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/metal-controller-manager/internal/ipxe/ipxe_server.go b/app/metal-controller-manager/internal/ipxe/ipxe_server.go index 1d8045743..049b177a1 100644 --- a/app/metal-controller-manager/internal/ipxe/ipxe_server.go +++ b/app/metal-controller-manager/internal/ipxe/ipxe_server.go @@ -23,6 +23,8 @@ import ( "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/talos-systems/go-procfs/procfs" + infrav1 "github.com/talos-systems/sidero/app/cluster-api-provider-sidero/api/v1alpha3" metalv1alpha1 "github.com/talos-systems/sidero/app/metal-controller-manager/api/v1alpha1" "github.com/talos-systems/sidero/app/metal-controller-manager/internal/server" @@ -289,7 +291,13 @@ func newAgentEnvironment() *metalv1alpha1.Environment { fmt.Sprintf("%s=%s:%s", constants.AgentEndpointArg, apiEndpoint, server.Port), } - args = append(args, extraAgentKernelArgs...) + cmdline := procfs.NewCmdline(strings.Join(args, " ")) + extra := procfs.NewCmdline(strings.Join(extraAgentKernelArgs, " ")) + + // override defaults with extra kernel agent params + for _, p := range extra.Parameters { + cmdline.Set(p.Key(), p) + } env := &metalv1alpha1.Environment{ ObjectMeta: metav1.ObjectMeta{ @@ -297,7 +305,7 @@ func newAgentEnvironment() *metalv1alpha1.Environment { }, Spec: metalv1alpha1.EnvironmentSpec{ Kernel: metalv1alpha1.Kernel{ - Args: args, + Args: cmdline.Strings(), }, }, }