Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0eb2df7
Use os-installer comming with metal-hammer instead from metal-images
majst01 Mar 3, 2026
0bb4b00
Try with os-installer which includes metal-networker
majst01 Mar 4, 2026
4507b40
Fix build
majst01 Mar 4, 2026
012a679
os-installer v0.2.0
majst01 Mar 4, 2026
23a5bd9
Try calling installer in chroot
majst01 Mar 11, 2026
f3348cc
Do not install the os-installer binary
majst01 Mar 11, 2026
cfab799
Remove commented code
majst01 Mar 11, 2026
d8ba527
no fprintf
majst01 Mar 13, 2026
299bbff
Try apiv2 os-installer
majst01 Mar 13, 2026
ee2ca10
Fix test
majst01 Mar 13, 2026
8b387c7
Use persistconfig from os-installer
majst01 Mar 14, 2026
70f4392
Go mod tidy
majst01 Mar 14, 2026
a8b4913
Write configuration also in chroot
majst01 Mar 16, 2026
6c91bf7
write configs in chroot
majst01 Mar 16, 2026
7a0db64
Debug log
majst01 Mar 16, 2026
ec2a06e
Fix
majst01 Mar 16, 2026
a7c835d
More debug log
majst01 Mar 16, 2026
cda612e
Recover
majst01 Mar 16, 2026
6eec5d4
More debug logs
majst01 Mar 16, 2026
5e8fcd6
More logs
majst01 Mar 16, 2026
2371b04
More logs
majst01 Mar 16, 2026
47efb82
Dump stack
majst01 Mar 16, 2026
78236d5
Progress
majst01 Mar 16, 2026
e2f3ee6
Progress
majst01 Mar 16, 2026
9d1a772
More debug
majst01 Mar 16, 2026
aaa66a7
Welcome back RootUUID
majst01 Mar 16, 2026
8f1ef44
More debug
majst01 Mar 16, 2026
c70efa0
Fix frr version detection
majst01 Mar 17, 2026
1f8dd56
Fix frr version detection
majst01 Mar 17, 2026
0f48ad7
Fix frr version detection
majst01 Mar 17, 2026
3a15378
Fix frr version detection
majst01 Mar 17, 2026
323d118
Fix nft validation
majst01 Mar 17, 2026
cc619d4
Fix nft validation
majst01 Mar 17, 2026
909bf80
Fix debug systemd reload
majst01 Mar 17, 2026
207a98c
Fix debug systemd enable
majst01 Mar 17, 2026
f81838d
Fix systemd enable
majst01 Mar 17, 2026
3cce52b
disable chrony temporarily
majst01 Mar 17, 2026
2e27a76
Fix systemd enable
majst01 Mar 17, 2026
0ab8940
Fix systemd enable
majst01 Mar 17, 2026
1c25a18
Fix systemd enable
majst01 Mar 17, 2026
1dac24c
Fix systemd enable
majst01 Mar 17, 2026
284046b
Write complete legacy install.yaml
majst01 Mar 18, 2026
593ae9f
Call Ignition
majst01 Mar 18, 2026
5daa8c9
Execute ignition in directory
majst01 Mar 18, 2026
69f4697
Next ignition try
majst01 Mar 18, 2026
113e52b
Fix suricata
majst01 Mar 18, 2026
c21850f
Cancel install after 10min
majst01 Mar 19, 2026
7e99e13
Less info logging
majst01 Mar 19, 2026
4c8de99
Pin
majst01 Mar 20, 2026
138e12c
write allocation.yaml during install
majst01 Mar 23, 2026
b6836dc
Remove duplicate chrony rendering
majst01 Mar 23, 2026
f1c9540
Pin
majst01 Apr 1, 2026
4cc57ac
Update deps
majst01 Apr 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
409 changes: 337 additions & 72 deletions cmd/install.go

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ package cmd

import (
"log/slog"
"reflect"
"testing"

"github.com/google/go-cmp/cmp"
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/metal-go/api/models"
"google.golang.org/protobuf/testing/protocmp"
)

func TestHammer_onlyNicsWithNeighbors(t *testing.T) {

tests := []struct {
name string
nics []*models.V1MachineNic
want []*models.V1MachineNic
want []*apiv2.MachineNic
}{
{
name: "4 interfaces, two with neighbors",
Expand All @@ -23,9 +25,9 @@ func TestHammer_onlyNicsWithNeighbors(t *testing.T) {
{Name: new("eth2"), Mac: new("aa:bb"), Neighbors: []*models.V1MachineNic{{Name: new("swp1"), Mac: new("cc:dd")}}},
{Name: new("eth3"), Mac: new("aa:bc"), Neighbors: []*models.V1MachineNic{{Name: new("swp2"), Mac: new("cc:de")}}},
},
want: []*models.V1MachineNic{
{Name: new("eth2"), Mac: new("aa:bb"), Neighbors: []*models.V1MachineNic{{Name: new("swp1"), Mac: new("cc:dd")}}},
{Name: new("eth3"), Mac: new("aa:bc"), Neighbors: []*models.V1MachineNic{{Name: new("swp2"), Mac: new("cc:de")}}},
want: []*apiv2.MachineNic{
{Name: "eth2", Mac: "aa:bb", Neighbors: []*apiv2.MachineNic{{Name: "swp1", Mac: "cc:dd"}}},
{Name: "eth3", Mac: "aa:bc", Neighbors: []*apiv2.MachineNic{{Name: "swp2", Mac: "cc:de"}}},
},
},
{
Expand All @@ -36,9 +38,9 @@ func TestHammer_onlyNicsWithNeighbors(t *testing.T) {
{Name: new("eth2"), Mac: new("aa:bb"), Neighbors: []*models.V1MachineNic{{Name: new("swp1"), Mac: new("cc:dd")}}},
{Name: new("eth3"), Mac: new("aa:bc"), Neighbors: []*models.V1MachineNic{{Name: new("swp2"), Mac: new("cc:de")}}},
},
want: []*models.V1MachineNic{
{Name: new("eth2"), Mac: new("aa:bb"), Neighbors: []*models.V1MachineNic{{Name: new("swp1"), Mac: new("cc:dd")}}},
{Name: new("eth3"), Mac: new("aa:bc"), Neighbors: []*models.V1MachineNic{{Name: new("swp2"), Mac: new("cc:de")}}},
want: []*apiv2.MachineNic{
{Name: "eth2", Mac: "aa:bb", Neighbors: []*apiv2.MachineNic{{Name: "swp1", Mac: "cc:dd"}}},
{Name: "eth3", Mac: "aa:bc", Neighbors: []*apiv2.MachineNic{{Name: "swp2", Mac: "cc:de"}}},
},
},
}
Expand All @@ -47,8 +49,9 @@ func TestHammer_onlyNicsWithNeighbors(t *testing.T) {
h := &hammer{
log: slog.Default(),
}
if got := h.onlyNicsWithNeighbors(tt.nics); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Hammer.onlyNicsWithNeighbors() = %v, want %v", got, tt.want)
got := h.onlyNicsWithNeighbors(tt.nics)
if diff := cmp.Diff(got, tt.want, protocmp.Transform()); diff != "" {
t.Errorf("Hammer.onlyNicsWithNeighbors() diff = %s", diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/reinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"time"

v1 "github.com/metal-stack/metal-api/pkg/api/v1"
kernelapi "github.com/metal-stack/metal-hammer/pkg/api"
"github.com/metal-stack/metal-hammer/pkg/kernel"
installerv1 "github.com/metal-stack/os-installer/api/v1"
)

func (h *hammer) abortReinstall(reason error, machineID string, primaryDiskWiped bool) error {
h.log.Error("reinstall cancelled => boot into existing OS...", "reason", reason)

var bootInfo *kernelapi.Bootinfo
var bootInfo *installerv1.Bootinfo

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
Expand All @@ -23,7 +23,7 @@ func (h *hammer) abortReinstall(reason error, machineID string, primaryDiskWiped
}

if resp != nil && resp.BootInfo != nil {
bootInfo = &kernelapi.Bootinfo{
bootInfo = &installerv1.Bootinfo{
Initrd: resp.BootInfo.Initrd,
Cmdline: resp.BootInfo.Cmdline,
Kernel: resp.BootInfo.Kernel,
Expand Down
53 changes: 6 additions & 47 deletions cmd/storage/filesystem.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package storage

import (
"encoding/json"
"fmt"
"log/slog"
gos "os"
Expand All @@ -16,24 +15,21 @@ import (
"github.com/u-root/u-root/pkg/mount/block"

"github.com/metal-stack/metal-go/api/models"
"github.com/metal-stack/metal-hammer/pkg/api"
"github.com/metal-stack/metal-hammer/pkg/os"
"github.com/metal-stack/metal-hammer/pkg/os/command"
"github.com/metal-stack/v"
)

type Filesystem struct {
log *slog.Logger

config models.V1FilesystemLayoutResponse
// chroot defines the root of the mounts
chroot string
// mounts are collected to be able to umount all in reverse order
mounts []string
fstabEntries fstabEntries
// disk is the legacy disk.json representatio
// TODO remove once old images are gone
disk api.Disk
log *slog.Logger
RootUUID string
RootUUID string
}

type fstabEntries []fstabEntry
Expand All @@ -50,11 +46,10 @@ type fstabEntry struct {

func New(log *slog.Logger, chroot string, config models.V1FilesystemLayoutResponse) *Filesystem {
return &Filesystem{
log: log,
config: config,
chroot: chroot,
fstabEntries: fstabEntries{},
disk: api.Disk{Device: "legacy", Partitions: []api.Partition{}},
log: log,
}
}

Expand Down Expand Up @@ -89,11 +84,6 @@ func (f *Filesystem) Run() error {
return fmt.Errorf("mount special filesystems failed:%w", err)
}

// TODO legacy image support, can be removed once all images in use do no depend on disk.json anymore
err = f.createDiskJSON()
if err != nil {
return fmt.Errorf("disk.json creation failed:%w", err)
}
return nil
}
func (f *Filesystem) Umount() {
Expand Down Expand Up @@ -389,19 +379,8 @@ func (f *Filesystem) mountFilesystems() error {
passno: passno,
}
f.fstabEntries = append(f.fstabEntries, fstabEntry)
// create legacy disk.json
switch fs.Label {
case "root", "efi", "varlib":
partUUID := properties["UUID"]
if fs.Label == "root" {
f.RootUUID = partUUID
}
part := api.Partition{
Label: fs.Label,
Filesystem: *fs.Format,
Properties: map[string]string{"UUID": properties["UUID"]},
}
f.disk.Partitions = append(f.disk.Partitions, part)
if fs.Label == "root" {
f.RootUUID = properties["UUID"]
}
}
return nil
Expand Down Expand Up @@ -474,26 +453,6 @@ func (f *Filesystem) CreateFSTab() error {
return f.fstabEntries.write(f.log, f.chroot)
}

func (f *Filesystem) createDiskJSON() error {
configdir := path.Join(f.chroot, "etc", "metal")
destination := path.Join(configdir, "disk.json")

if _, err := gos.Stat(configdir); err != nil && gos.IsNotExist(err) {
if err := gos.MkdirAll(configdir, 0755); err != nil {
return err
}
} else if err != nil {
return err
}

j, err := json.MarshalIndent(f.disk, "", " ")
if err != nil {
return fmt.Errorf("unable to marshal to json %w", err)
}
f.log.Info("create legacy disk.json", "content", string(j))
return gos.WriteFile(destination, j, 0600)
}

func mountFs(log *slog.Logger, chroot string, fs models.V1Filesystem) (string, error) {
if fs.Format == nil || *fs.Format == "swap" || *fs.Format == "" || *fs.Format == "tmpfs" {
return "", nil
Expand Down
Loading
Loading