metropolis: use new OS image format for install
This switches the USB and SSH installation methods to the new OS image
format based on OCI artifacts.
When stored on disk, the new format consists of a directory containing
an OCI layout, instead of a single file. This means that all steps which
copy or upload an image now need to handle a tree of files.
Change-Id: I526d32f5c50bd74f513f785118768a56b2655fa0
Reviewed-on: https://review.monogon.dev/c/monogon/+/4090
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/takeover/takeover.go b/metropolis/cli/takeover/takeover.go
index 07c44de..b8ace66 100644
--- a/metropolis/cli/takeover/takeover.go
+++ b/metropolis/cli/takeover/takeover.go
@@ -4,7 +4,6 @@
package main
import (
- "archive/zip"
_ "embed"
"fmt"
"io"
@@ -23,6 +22,7 @@
"source.monogon.dev/osbase/build/mkimage/osimage"
"source.monogon.dev/osbase/kexec"
netdump "source.monogon.dev/osbase/net/dump"
+ "source.monogon.dev/osbase/oci"
"source.monogon.dev/osbase/structfs"
)
@@ -94,19 +94,9 @@
return nil, err
}
- bundleBlob, err := structfs.OSPathBlob(filepath.Join(filepath.Dir(currPath), "bundle.zip"))
+ image, err := oci.ReadLayout(filepath.Join(filepath.Dir(currPath), "osimage"))
if err != nil {
- return nil, err
- }
-
- bundleRaw, err := bundleBlob.Open()
- if err != nil {
- return nil, err
- }
- defer bundleRaw.Close()
- bundle, err := zip.NewReader(bundleRaw.(io.ReaderAt), bundleBlob.Size())
- if err != nil {
- return nil, fmt.Errorf("failed to open node bundle: %w", err)
+ return nil, fmt.Errorf("failed to read OS image: %w", err)
}
// Dump the current network configuration
@@ -140,7 +130,7 @@
return nil, fmt.Errorf("failed marshaling: %w", err)
}
- oParams, err := setupOSImageParams(bundle, nodeParamsRaw, target)
+ oParams, err := setupOSImageParams(image, nodeParamsRaw, target)
if err != nil {
return nil, err
}
@@ -170,15 +160,19 @@
return nil, fmt.Errorf("failed to write initramfs into memory-backed file: %w", err)
}
- // Append this executable, the bundle and node params to initramfs
+ // Append this executable, node params and OS image to initramfs.
self, err := structfs.OSPathBlob("/proc/self/exe")
if err != nil {
return nil, err
}
+ imageLayout, err := oci.CreateLayout(image)
+ if err != nil {
+ return nil, err
+ }
root := structfs.Tree{
structfs.File("init", self, structfs.WithPerm(0o755)),
structfs.File("params.pb", structfs.Bytes(nodeParamsRaw)),
- structfs.File("bundle.zip", bundleBlob),
+ structfs.Dir("osimage", imageLayout),
}
compressedW, err := zstd.NewWriter(initramfsFile, zstd.WithEncoderLevel(1))
if err != nil {