Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ RUN mkdir -p /work/etc/lvm /work/etc/ssl/certs /work/lib/firmware/intel/ice/ddp/
&& cp /usr/share/zoneinfo/Etc/UTC /work/etc/localtime
COPY lvmlocal.conf metal.key metal.key.pub passwd varrun Makefile .git /work/
COPY --from=r.metal-stack.io/metal/supermicro:2.14.0 /usr/bin/sum /work/
COPY --from=ghcr.io/metal-stack/os-installer:v0.2.0 /os-installer /work/os-installer
COPY --from=builder /work/ice.pkg /work/ice.pkg
COPY --from=builder /work/bin/metal-hammer /work/bin/
RUN make ramdisk
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ramdisk:
-format=cpio -build=bb \
-defaultsh=/bin/bash \
-files="bin/metal-hammer:bbin/uinit" \
-files="os-installer:bin/os-installer" \
-files="/bin/bash:bin/bash" \
-files="/bin/netstat:bin/netstat" \
-files="/etc/localtime:etc/localtime" \
Expand Down
26 changes: 18 additions & 8 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/metal-stack/metal-hammer/cmd/utils"
"github.com/metal-stack/metal-hammer/pkg/api"
apiv1 "github.com/metal-stack/os-installer/api/v1"

"github.com/metal-stack/metal-go/api/models"
img "github.com/metal-stack/metal-hammer/cmd/image"
Expand All @@ -22,7 +22,7 @@ import (
)

// Install a given image to the disk by using genuinetools/img
func (h *hammer) Install(machine *models.V1MachineResponse) (*api.Bootinfo, error) {
func (h *hammer) Install(machine *models.V1MachineResponse) (*apiv1.Bootinfo, error) {
s := storage.New(h.log, h.chrootPrefix, *h.filesystemLayout)
err := s.Run()
if err != nil {
Expand Down Expand Up @@ -60,7 +60,7 @@ func (h *hammer) Install(machine *models.V1MachineResponse) (*api.Bootinfo, erro

// install will execute /install.sh in the pulled docker image which was extracted onto disk
// to finish installation e.g. install mbr, grub, write network and filesystem config
func (h *hammer) install(prefix string, machine *models.V1MachineResponse, rootUUID string) (*api.Bootinfo, error) {
func (h *hammer) install(prefix string, machine *models.V1MachineResponse, rootUUID string) (*apiv1.Bootinfo, error) {
h.log.Info("install", "image", machine.Allocation.Image.URL)

err := h.writeInstallerConfig(machine, rootUUID)
Expand All @@ -78,9 +78,19 @@ func (h *hammer) install(prefix string, machine *models.V1MachineResponse, rootU
return nil, err
}

installBinary := "/install.sh"
if fileExists(path.Join(prefix, "install-go")) {
installBinary = "/install-go"
// TODO we still run the binary instead of calling it as a library because it needs to run in a chroot env
// Can be done once we figure out howto fork itself in the chroot.
installBinary := "/bin/os-installer"
installBinaryInChroot := path.Join(prefix, installBinary)

_, err = utils.Copy(installBinary, installBinaryInChroot)
if err != nil {
return nil, fmt.Errorf("unable to copy %s to %s %w", installBinary, prefix, err)
}

err = os.Chmod(installBinaryInChroot, 0755)
if err != nil {
return nil, fmt.Errorf("unable to chmod %w", err)
}

h.log.Info("running install", "binary", installBinary, "prefix", prefix)
Expand Down Expand Up @@ -109,7 +119,7 @@ func (h *hammer) install(prefix string, machine *models.V1MachineResponse, rootU
}
h.log.Info("finish running", "binary", installBinary)

err = os.Remove(path.Join(prefix, installBinary))
err = os.Remove(installBinaryInChroot)
if err != nil {
h.log.Warn("unable to remove, ignoring", "binary", installBinary, "error", err)
}
Expand Down Expand Up @@ -219,7 +229,7 @@ func (h *hammer) writeInstallerConfig(machine *models.V1MachineResponse, rootUUi
raidEnabled = true
}

y := &api.InstallerConfig{
y := &apiv1.InstallerConfig{
Hostname: *alloc.Hostname,
SSHPublicKey: sshPubkeys,
Networks: alloc.Networks,
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"
apiv1 "github.com/metal-stack/os-installer/api/v1"
"github.com/metal-stack/metal-hammer/pkg/kernel"
)

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 *apiv1.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 = &apiv1.Bootinfo{
Initrd: resp.BootInfo.Initrd,
Cmdline: resp.BootInfo.Cmdline,
Kernel: resp.BootInfo.Kernel,
Expand Down
8 changes: 4 additions & 4 deletions cmd/storage/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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"
apiv1 "github.com/metal-stack/os-installer/api/v1"
"github.com/metal-stack/metal-hammer/pkg/os"
"github.com/metal-stack/metal-hammer/pkg/os/command"
"github.com/metal-stack/v"
Expand All @@ -31,7 +31,7 @@ type Filesystem struct {
fstabEntries fstabEntries
// disk is the legacy disk.json representatio
// TODO remove once old images are gone
disk api.Disk
disk apiv1.Disk
log *slog.Logger
RootUUID string
}
Expand All @@ -53,7 +53,7 @@ func New(log *slog.Logger, chroot string, config models.V1FilesystemLayoutRespon
config: config,
chroot: chroot,
fstabEntries: fstabEntries{},
disk: api.Disk{Device: "legacy", Partitions: []api.Partition{}},
disk: apiv1.Disk{Device: "legacy", Partitions: []apiv1.Partition{}},
log: log,
}
}
Expand Down Expand Up @@ -396,7 +396,7 @@ func (f *Filesystem) mountFilesystems() error {
if fs.Label == "root" {
f.RootUUID = partUUID
}
part := api.Partition{
part := apiv1.Partition{
Label: fs.Label,
Filesystem: *fs.Format,
Properties: map[string]string{"UUID": properties["UUID"]},
Expand Down
50 changes: 26 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ require (
github.com/metal-stack/go-lldpd v0.4.11
github.com/metal-stack/metal-api v0.43.0
github.com/metal-stack/metal-go v0.43.0
github.com/metal-stack/pixie v0.3.7
github.com/metal-stack/os-installer v0.2.0
github.com/metal-stack/pixie v0.4.0
github.com/metal-stack/v v1.0.3
// archiver must stay in version v2.1.0, see replace below
github.com/mholt/archiver v3.1.1+incompatible
Expand Down Expand Up @@ -44,6 +45,8 @@ require (
github.com/avast/retry-go/v4 v4.7.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
github.com/creack/pty v1.1.24 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
Expand All @@ -59,28 +62,28 @@ require (
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/analysis v0.24.1 // indirect
github.com/go-openapi/errors v0.22.5 // indirect
github.com/go-openapi/jsonpointer v0.22.3 // indirect
github.com/go-openapi/jsonreference v0.21.3 // indirect
github.com/go-openapi/analysis v0.24.2 // indirect
github.com/go-openapi/errors v0.22.6 // indirect
github.com/go-openapi/jsonpointer v0.22.5 // indirect
github.com/go-openapi/jsonreference v0.21.5 // indirect
github.com/go-openapi/loads v0.23.2 // indirect
github.com/go-openapi/runtime v0.29.2 // indirect
github.com/go-openapi/spec v0.22.1 // indirect
github.com/go-openapi/spec v0.22.4 // indirect
github.com/go-openapi/strfmt v0.25.0 // indirect
github.com/go-openapi/swag v0.24.1 // indirect
github.com/go-openapi/swag/cmdutils v0.24.0 // indirect
github.com/go-openapi/swag/conv v0.25.4 // indirect
github.com/go-openapi/swag/fileutils v0.25.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
github.com/go-openapi/swag/loading v0.25.4 // indirect
github.com/go-openapi/swag/mangling v0.25.4 // indirect
github.com/go-openapi/swag/netutils v0.24.0 // indirect
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
github.com/go-openapi/swag v0.25.5 // indirect
github.com/go-openapi/swag/cmdutils v0.25.5 // indirect
github.com/go-openapi/swag/conv v0.25.5 // indirect
github.com/go-openapi/swag/fileutils v0.25.5 // indirect
github.com/go-openapi/swag/jsonname v0.25.5 // indirect
github.com/go-openapi/swag/jsonutils v0.25.5 // indirect
github.com/go-openapi/swag/loading v0.25.5 // indirect
github.com/go-openapi/swag/mangling v0.25.5 // indirect
github.com/go-openapi/swag/netutils v0.25.5 // indirect
github.com/go-openapi/swag/stringutils v0.25.5 // indirect
github.com/go-openapi/swag/typeutils v0.25.5 // indirect
github.com/go-openapi/swag/yamlutils v0.25.5 // indirect
github.com/go-openapi/validate v0.25.1 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
Expand All @@ -98,11 +101,11 @@ require (
github.com/lestrrat-go/option/v2 v2.0.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/lldp v0.0.0-20150915211757-afd9f83164c5 // indirect
github.com/metal-stack/metal-lib v0.23.5 // indirect
github.com/metal-stack/security v0.9.5 // indirect
github.com/metal-stack/metal-lib v0.24.0 // indirect
github.com/metal-stack/security v0.9.6 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -114,10 +117,9 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/prometheus/procfs v0.19.1 // indirect
github.com/prometheus/prometheus v0.304.0 // indirect
github.com/rekby/gpt v0.0.0-20200614112001-7da10aec5566 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/samber/lo v1.52.0 // indirect
github.com/samber/slog-common v0.20.0 // indirect
github.com/segmentio/asm v1.2.1 // indirect
Expand Down
Loading