Skip to content

Commit

Permalink
fix: overwrite kernel args from --extra-agent-kernel-args
Browse files Browse the repository at this point in the history
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 siderolabs/go-procfs#5

Fixes #251

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Dec 17, 2020
1 parent 71872d0 commit b790d7a
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MODULE := $(shell head -1 go.mod | cut -d' ' -f2)

ARTIFACTS := _out
PKGS ?= ./...
TALOS_RELEASE ?= v0.7.0
TALOS_RELEASE ?= v0.8.0-alpha.3

SFYRA_CLUSTERCTL_CONFIG ?= $(HOME)/.cluster-api/clusterctl.sfyra.yaml

Expand Down
16 changes: 12 additions & 4 deletions app/metal-controller-manager/internal/ipxe/ipxe_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,7 +52,7 @@ exit

var (
apiEndpoint string
extraAgentKernelArgs []string
extraAgentKernelArgs string
c client.Client
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -289,15 +291,21 @@ 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{
Name: "agent",
},
Spec: metalv1alpha1.EnvironmentSpec{
Kernel: metalv1alpha1.Kernel{
Args: args,
Args: cmdline.Strings(),
},
},
}
Expand Down
5 changes: 1 addition & 4 deletions app/metal-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"flag"
"fmt"
"os"
"strings"
"time"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ require (
github.com/prometheus/procfs v0.2.0 // indirect
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/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
github.com/talos-systems/talos/pkg/machinery v0.0.0-20201116215021-c16c1c88f95d
github.com/talos-systems/talos/pkg/machinery v0.0.0-20201215150852-17830b91527e
go.uber.org/zap v1.14.1 // indirect
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,12 @@ github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.8
github.com/talos-systems/cluster-api-control-plane-provider-talos v0.1.0-alpha.8/go.mod h1:m7IozKpXPc+uqHBglJuJ7ivhtkyOgd4n/ezy2iDicEg=
github.com/talos-systems/crypto v0.2.0 h1:UwT8uhJ0eDlklY0vYwo1+LGoFgiqkPqjQnae6j8UNYE=
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.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=
Expand All @@ -533,8 +533,8 @@ github.com/talos-systems/net v0.2.0 h1:QJ2ofYboG1Zjew9b+3RAjtLIfL0mIONGuc6/LyO68
github.com/talos-systems/net v0.2.0/go.mod h1:VreSAyRmxMtqussAHSKMKkJQa1YwBTSVfkmE4Jydam4=
github.com/talos-systems/talos/pkg/machinery v0.0.0-20201020161939-d2583e228288 h1:YIDpZsiYrdmAvIm8gGq7eHpsgkXZxWUX/Uj3oo7Pzh8=
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=
Expand Down
5 changes: 1 addition & 4 deletions hack/scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,5 +35,5 @@ ${PREFIX} "${INTEGRATION_TEST}" test integration \
--talosctl-path "${TALOSCTL}" \
--clusterctl-config "${CLUSTERCTL_CONFIG}" \
--power-simulated-explicit-failure-prob=0.1 \
--power-simulated-silent-failure-prob=0.1 \
--power-simulated-silent-failure-prob=0.0 \
${REGISTRY_MIRROR_FLAGS}
14 changes: 7 additions & 7 deletions sfyra/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ 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-retry v0.1.1-0.20200922131245-752f081252cf
github.com/talos-systems/go-procfs v0.0.0-20201215195843-16ce2ef52acd
github.com/talos-systems/go-retry v0.1.1-0.20201113203059-8c63d290a688
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 v0.0.0-20201215150852-17830b91527e
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
k8s.io/api v0.20.0
k8s.io/apiextensions-apiserver v0.19.1
k8s.io/apimachinery v0.19.3
k8s.io/client-go v0.19.3
k8s.io/apimachinery v0.20.0
k8s.io/client-go v0.20.0
sigs.k8s.io/cluster-api v0.3.9
sigs.k8s.io/controller-runtime v0.6.3
)
Loading

0 comments on commit b790d7a

Please sign in to comment.