From ada74360bd41ed327935a466254a759f020d72c8 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=tty0 console=ttyS1 panic=5"`. See also https://github.com/talos-systems/go-procfs/pull/5 Fixes #251 Signed-off-by: Andrey Smirnov --- .../internal/ipxe/ipxe_server.go | 16 ++++++++++++---- app/metal-controller-manager/main.go | 5 +---- go.mod | 2 +- go.sum | 4 ++-- hack/scripts/integration-test.sh | 3 --- sfyra/go.mod | 4 ++-- sfyra/go.sum | 6 ++++++ 7 files changed, 24 insertions(+), 16 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..e764cd717 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" @@ -50,7 +52,7 @@ exit var ( apiEndpoint string - extraAgentKernelArgs []string + extraAgentKernelArgs string c client.Client ) @@ -147,7 +149,7 @@ func ipxeHandler(w http.ResponseWriter, r *http.Request) { } } -func ServeIPXE(endpoint string, args []string, mgrClient client.Client) error { +func ServeIPXE(endpoint, args string, mgrClient client.Client) error { apiEndpoint = endpoint extraAgentKernelArgs = args c = mgrClient @@ -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(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(), }, }, } diff --git a/app/metal-controller-manager/main.go b/app/metal-controller-manager/main.go index aa927a3bf..086501613 100644 --- a/app/metal-controller-manager/main.go +++ b/app/metal-controller-manager/main.go @@ -8,7 +8,6 @@ import ( "flag" "fmt" "os" - "strings" "time" corev1 "k8s.io/api/core/v1" @@ -164,9 +163,7 @@ func main() { } } - args := strings.Split(extraAgentKernelArgs, ",") - - if err := ipxe.ServeIPXE(apiEndpoint, args, mgr.GetClient()); err != nil { + if err := ipxe.ServeIPXE(apiEndpoint, extraAgentKernelArgs, mgr.GetClient()); err != nil { setupLog.Error(err, "unable to start iPXE server", "controller", "Environment") os.Exit(1) } diff --git a/go.mod b/go.mod index cea7649f9..2178fb183 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.8 github.com/talos-systems/crypto v0.2.1-0.20201028152949-d0c3eef149ec // indirect github.com/talos-systems/go-blockdevice v0.1.1-0.20201111103554-874213371a3f - github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 + github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd github.com/talos-systems/go-retry v0.1.1-0.20200922131245-752f081252cf github.com/talos-systems/go-smbios v0.0.0-20200807005123-80196199691e github.com/talos-systems/net v0.2.0 diff --git a/go.sum b/go.sum index 0880a9ac8..6b1214b5a 100644 --- a/go.sum +++ b/go.sum @@ -522,8 +522,8 @@ github.com/talos-systems/crypto v0.2.1-0.20201028152949-d0c3eef149ec h1:qO6KZJ1X github.com/talos-systems/crypto v0.2.1-0.20201028152949-d0c3eef149ec/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= github.com/talos-systems/go-blockdevice v0.1.1-0.20201111103554-874213371a3f h1:DiWsa6+uyi9fuxWBs9NpLYDCs3OIg+HwEvSlVjkAm0U= github.com/talos-systems/go-blockdevice v0.1.1-0.20201111103554-874213371a3f/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo= -github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 h1:FND/LgzFHTBdJBOeZVzdO6B47kxQZvSIzb9AMIXYotg= -github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45/go.mod h1:ATyUGFQIW8OnbnmvqefZWVPgL9g+CAmXHfkgny21xX8= +github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd h1:BAd+tKk/iDnQk4/MOGI2Pt/QdwisVFXa9ch24p/h8LI= +github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd/go.mod h1:ATyUGFQIW8OnbnmvqefZWVPgL9g+CAmXHfkgny21xX8= github.com/talos-systems/go-retry v0.1.0/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lIW2MS5VdDaMtoKM= github.com/talos-systems/go-retry v0.1.1-0.20200922131245-752f081252cf h1:JzyT28FxRDndO59tFKA1IyGb9uWpJX429PPAfjc0dVQ= github.com/talos-systems/go-retry v0.1.1-0.20200922131245-752f081252cf/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lIW2MS5VdDaMtoKM= diff --git a/hack/scripts/integration-test.sh b/hack/scripts/integration-test.sh index bf4d73d02..2eabfe4a1 100755 --- a/hack/scripts/integration-test.sh +++ b/hack/scripts/integration-test.sh @@ -18,9 +18,6 @@ function build_registry_mirrors { REGISTRY_MIRROR_FLAGS="${REGISTRY_MIRROR_FLAGS} --registry-mirrors ${registry}=http://${addr}:5000" done - - local addr=`python3 -c "import socket; print(socket.gethostbyname('registry.ci.svc'))"` - REGISTRY_MIRROR_FLAGS="${REGISTRY_MIRROR_FLAGS} --registry-mirrors registry.ci.svc:5000=http://${addr}:5000" else REGISTRY_MIRROR_FLAGS=${REGISTRY_MIRROR_FLAGS:-} fi diff --git a/sfyra/go.mod b/sfyra/go.mod index b2a1cc15e..11d886979 100644 --- a/sfyra/go.mod +++ b/sfyra/go.mod @@ -13,12 +13,12 @@ require ( github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.6 github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.8 github.com/talos-systems/go-loadbalancer v0.1.1-0.20201015151439-a4457024d518 - github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 + github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd github.com/talos-systems/go-retry v0.1.1-0.20200922131245-752f081252cf github.com/talos-systems/net v0.2.0 github.com/talos-systems/sidero v0.1.0-alpha.1.0.20200915181156-11a0a80e3d8b github.com/talos-systems/talos v0.7.0 - github.com/talos-systems/talos/pkg/machinery v0.0.0-20201116215021-c16c1c88f95d + github.com/talos-systems/talos/pkg/machinery v0.0.0-20201215150852-17830b91527e google.golang.org/grpc v1.29.1 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 k8s.io/api v0.19.3 diff --git a/sfyra/go.sum b/sfyra/go.sum index cc1c57885..bc997bb57 100644 --- a/sfyra/go.sum +++ b/sfyra/go.sum @@ -795,6 +795,8 @@ github.com/talos-systems/crypto v0.2.0 h1:UwT8uhJ0eDlklY0vYwo1+LGoFgiqkPqjQnae6j github.com/talos-systems/crypto v0.2.0/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= github.com/talos-systems/crypto v0.2.1-0.20201028152949-d0c3eef149ec h1:qO6KZJ1XbXQmkTcaonJYsTduNrKWGFfp9Tykc63raA4= github.com/talos-systems/crypto v0.2.1-0.20201028152949-d0c3eef149ec/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= +github.com/talos-systems/crypto v0.2.1-0.20201203131813-e0dd56ac4745 h1:Smw6ebFiEiwrkaOD2hEYYb+xkIhQTMZNq3WVYKLszB8= +github.com/talos-systems/crypto v0.2.1-0.20201203131813-e0dd56ac4745/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= github.com/talos-systems/go-blockdevice v0.1.1-0.20201030204209-b4e67d73d70d/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo= github.com/talos-systems/go-blockdevice v0.1.1-0.20201111103554-874213371a3f h1:DiWsa6+uyi9fuxWBs9NpLYDCs3OIg+HwEvSlVjkAm0U= github.com/talos-systems/go-blockdevice v0.1.1-0.20201111103554-874213371a3f/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo= @@ -803,6 +805,8 @@ github.com/talos-systems/go-loadbalancer v0.1.1-0.20201015151439-a4457024d518 h1 github.com/talos-systems/go-loadbalancer v0.1.1-0.20201015151439-a4457024d518/go.mod h1:L0uLhCBUQVkdBqtnxqbrw+wzopQyoeluPos8okqdxLo= github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 h1:FND/LgzFHTBdJBOeZVzdO6B47kxQZvSIzb9AMIXYotg= github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45/go.mod h1:ATyUGFQIW8OnbnmvqefZWVPgL9g+CAmXHfkgny21xX8= +github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd h1:BAd+tKk/iDnQk4/MOGI2Pt/QdwisVFXa9ch24p/h8LI= +github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd/go.mod h1:ATyUGFQIW8OnbnmvqefZWVPgL9g+CAmXHfkgny21xX8= github.com/talos-systems/go-retry v0.1.0 h1:O+OeZR54CQ1+ch99p/81Pqi5GqJH6LIu1MTN/N0vd78= github.com/talos-systems/go-retry v0.1.0/go.mod h1:HiXQqyVStZ35uSY/MTLWVvQVmC3lIW2MS5VdDaMtoKM= github.com/talos-systems/go-retry v0.1.1-0.20200922131245-752f081252cf h1:JzyT28FxRDndO59tFKA1IyGb9uWpJX429PPAfjc0dVQ= @@ -819,6 +823,8 @@ github.com/talos-systems/talos/pkg/machinery v0.0.0-20201020161939-d2583e228288 github.com/talos-systems/talos/pkg/machinery v0.0.0-20201020161939-d2583e228288/go.mod h1:Oa6kzDfA2SSosSITBXf6XMl/cvSfI330LiceB5wO/Dg= github.com/talos-systems/talos/pkg/machinery v0.0.0-20201116215021-c16c1c88f95d h1:tLTrYnH6VzZyXBAoX1BLp2xZ45ZpgQsHkThlB/414bU= github.com/talos-systems/talos/pkg/machinery v0.0.0-20201116215021-c16c1c88f95d/go.mod h1:4xp8SuXcr15gHoFNeVwimzri0fVgzPjZQY1ZLEBsrbk= +github.com/talos-systems/talos/pkg/machinery v0.0.0-20201215150852-17830b91527e h1:LehR768iGTf1n2uFFG8UPuXaIYoU6souprG38xf8awM= +github.com/talos-systems/talos/pkg/machinery v0.0.0-20201215150852-17830b91527e/go.mod h1:uPRriED1lzoGGk3GQDBgNWl288rYYrqMI/DL8YiHEks= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=