Skip to content

Commit

Permalink
fix: allow platform cmdline args to be platform-specific
Browse files Browse the repository at this point in the history
Fix Equnix Metal (where proper arm64 args are known) and metal platform
(using generic arm64 console arg).

Other platforms might need to be updated, but correct settings are not
known at the moment.

Fixes #8529

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Apr 2, 2024
1 parent 7a68504 commit 090143b
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cmd/installer/pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Install(ctx context.Context, p runtime.Platform, mode Mode, opts *Options)
cmdline.Append(constants.KernelParamConfig, opts.ConfigSource)
}

cmdline.SetAll(p.KernelArgs().Strings())
cmdline.SetAll(p.KernelArgs(opts.Arch).Strings())

// first defaults, then extra kernel args to allow extra kernel args to override defaults
if err := cmdline.AppendAll(kernel.DefaultArgs); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/app/machined/pkg/controllers/block/devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package block_test

import (
"os"
"testing"

"github.com/cosi-project/runtime/pkg/resource/rtestutils"
Expand All @@ -25,6 +26,10 @@ func TestDevicesSuite(t *testing.T) {
}

func (suite *DevicesSuite) TestDiscover() {
if os.Geteuid() != 0 {
suite.T().Skip("skipping test; must be root to use inotify")
}

suite.Require().NoError(suite.Runtime().RegisterController(&blockctrls.DevicesController{}))

// these devices should always exist on Linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
package kobject

import (
"errors"
"fmt"
"sync"

"github.com/mdlayher/kobject"
"go.uber.org/zap"
"golang.org/x/sys/unix"
)

const readBufferSize = 64 * 1024 * 1024
Expand Down Expand Up @@ -79,7 +77,7 @@ func (w *Watcher) Run(logger *zap.Logger) <-chan *Event {
for {
ev, err := w.cli.Receive()
if err != nil {
if !errors.Is(err, unix.EBADF) {
if err.Error() == "use of closed file" { // unfortunately not an exported error, just errors.New()
logger.Error("failed to receive kobject event", zap.Error(err))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ func (mock *platformMock) Mode() v1alpha1runtime.Mode {
return v1alpha1runtime.ModeCloud
}

func (mock *platformMock) KernelArgs() procfs.Parameters {
func (mock *platformMock) KernelArgs(string) procfs.Parameters {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/app/machined/pkg/runtime/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Platform interface {
Configuration(context.Context, state.State) ([]byte, error)

// KernelArgs returns additional kernel arguments which should be injected for the kernel boot.
KernelArgs() procfs.Parameters
KernelArgs(arch string) procfs.Parameters

// NetworkConfiguration fetches network configuration from the platform metadata.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (a *AWS) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (a *AWS) KernelArgs() procfs.Parameters {
func (a *AWS) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (a *Azure) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (a *Azure) KernelArgs() procfs.Parameters {
func (a *Azure) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS0,115200n8"),
procfs.NewParameter("earlyprintk").Append("ttyS0,115200"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *Container) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (c *Container) KernelArgs() procfs.Parameters {
func (c *Container) KernelArgs(string) procfs.Parameters {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (d *DigitalOcean) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (d *DigitalOcean) KernelArgs() procfs.Parameters {
func (d *DigitalOcean) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS0").Append("tty0").Append("tty1"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,18 @@ func (p *EquinixMetal) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (p *EquinixMetal) KernelArgs() procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS1,115200n8"),
func (p *EquinixMetal) KernelArgs(arch string) procfs.Parameters {
switch arch {
case "amd64":
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS1,115200n8"),
}
case "arm64":
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyAMA0,115200"),
}
default:
return nil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (e *Exoscale) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (e *Exoscale) KernelArgs() procfs.Parameters {
func (e *Exoscale) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (g *GCP) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (g *GCP) KernelArgs() procfs.Parameters {
func (g *GCP) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (h *Hcloud) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (h *Hcloud) KernelArgs() procfs.Parameters {
func (h *Hcloud) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
15 changes: 12 additions & 3 deletions internal/app/machined/pkg/runtime/v1alpha1/platform/metal/metal.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ func readConfigFromISO() ([]byte, error) {
}

// KernelArgs implements the runtime.Platform interface.
func (m *Metal) KernelArgs() procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS0").Append("tty0"),
func (m *Metal) KernelArgs(arch string) procfs.Parameters {
switch arch {
case "amd64":
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyS0").Append("tty0"),
}
case "arm64":
return []*procfs.Parameter{
procfs.NewParameter("console").Append("ttyAMA0").Append("tty0"),
}
default:
return nil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (n *Nocloud) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (n *Nocloud) KernelArgs() procfs.Parameters {
func (n *Nocloud) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (o *OpenNebula) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (o *OpenNebula) KernelArgs() procfs.Parameters {
func (o *OpenNebula) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (o *Openstack) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (o *Openstack) KernelArgs() procfs.Parameters {
func (o *Openstack) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (o *Oracle) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (o *Oracle) KernelArgs() procfs.Parameters {
func (o *Oracle) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s *Scaleway) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (s *Scaleway) KernelArgs() procfs.Parameters {
func (s *Scaleway) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter("console").Append("tty1").Append("ttyS0"),
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (u *UpCloud) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (u *UpCloud) KernelArgs() procfs.Parameters {
func (u *UpCloud) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (v *VMware) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (v *VMware) KernelArgs() procfs.Parameters {
func (v *VMware) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter(constants.KernelParamConfig).Append(constants.ConfigGuestInfo),
procfs.NewParameter("console").Append("tty0").Append("ttyS0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (v *VMware) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (v *VMware) KernelArgs() procfs.Parameters {
func (v *VMware) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (v *Vultr) Mode() runtime.Mode {
}

// KernelArgs implements the runtime.Platform interface.
func (v *Vultr) KernelArgs() procfs.Parameters {
func (v *Vultr) KernelArgs(string) procfs.Parameters {
return []*procfs.Parameter{
procfs.NewParameter(constants.KernelParamNetIfnames).Append("0"),
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/imager/imager.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (i *Imager) buildCmdline() error {

// platform kernel args
cmdline.Append(constants.KernelParamPlatform, p.Name())
cmdline.SetAll(p.KernelArgs().Strings())
cmdline.SetAll(p.KernelArgs(i.prof.Arch).Strings())

// board kernel args
if i.prof.Board != "" && !quirks.New(i.prof.Version).SupportsOverlay() {
Expand Down

0 comments on commit 090143b

Please sign in to comment.