Skip to content

Commit

Permalink
fix: handle overlay partition options
Browse files Browse the repository at this point in the history
Handling of Overlay PartitionOpts was missed in the previous code.

Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
frezbo committed Mar 14, 2024
1 parent 465b9a4 commit 952801d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,12 @@ RUN apk add --no-cache --update --no-scripts grub

FROM scratch AS install-artifacts-amd64
COPY --from=pkg-kernel-amd64 /boot/vmlinuz /usr/install/amd64/vmlinuz
COPY --from=pkg-kernel-amd64 /dtb /usr/install/amd64/dtb
COPY --from=initramfs-archive-amd64 /initramfs.xz /usr/install/amd64/initramfs.xz
COPY --from=pkg-sd-boot-amd64 /linuxx64.efi.stub /usr/install/amd64/systemd-stub.efi
COPY --from=pkg-sd-boot-amd64 /systemd-bootx64.efi /usr/install/amd64/systemd-boot.efi

FROM scratch AS install-artifacts-arm64
COPY --from=pkg-kernel-arm64 /boot/vmlinuz /usr/install/arm64/vmlinuz
COPY --from=pkg-kernel-arm64 /dtb /usr/install/arm64/dtb
COPY --from=initramfs-archive-arm64 /initramfs.xz /usr/install/arm64/initramfs.xz
COPY --from=pkg-sd-boot-arm64 /linuxaa64.efi.stub /usr/install/arm64/systemd-stub.efi
COPY --from=pkg-sd-boot-arm64 /systemd-bootaa64.efi /usr/install/arm64/systemd-boot.efi
Expand Down
18 changes: 16 additions & 2 deletions cmd/installer/pkg/install/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/board"
"github.com/siderolabs/talos/internal/pkg/mount"
"github.com/siderolabs/talos/internal/pkg/partition"
"github.com/siderolabs/talos/pkg/imager/quirks"
"github.com/siderolabs/talos/pkg/machinery/constants"
)

Expand All @@ -48,7 +49,7 @@ type Device struct {

// NewManifest initializes and returns a Manifest.
//
//nolint:gocyclo
//nolint:gocyclo,cyclop
func NewManifest(mode Mode, uefiOnlyBoot bool, bootLoaderPresent bool, opts *Options) (manifest *Manifest, err error) {
manifest = &Manifest{
Devices: map[string]Device{},
Expand All @@ -58,7 +59,7 @@ func NewManifest(mode Mode, uefiOnlyBoot bool, bootLoaderPresent bool, opts *Opt
Printf: opts.Printf,
}

if opts.Board != constants.BoardNone {
if opts.Board != constants.BoardNone && !quirks.New(opts.Version).SupportsOverlay() {
if uefiOnlyBoot {
return nil, errors.New("board option can't be used with uefi-only-boot")
}
Expand All @@ -73,6 +74,19 @@ func NewManifest(mode Mode, uefiOnlyBoot bool, bootLoaderPresent bool, opts *Opt
manifest.PartitionOptions = b.PartitionOptions()
}

if opts.OverlayInstaller != nil {
overlayOpts, getOptsErr := opts.OverlayInstaller.GetOptions(opts.ExtraOptions)
if getOptsErr != nil {
return nil, fmt.Errorf("failed to get overlay installer options: %w", getOptsErr)
}

if overlayOpts.PartitionOptions.Offset != 0 {
manifest.PartitionOptions = &runtime.PartitionOptions{
PartitionsOffset: overlayOpts.PartitionOptions.Offset,
}
}
}

// TODO: legacy, to support old Talos initramfs, assume force if boot partition not found
if !bootLoaderPresent {
opts.Force = true
Expand Down
13 changes: 8 additions & 5 deletions pkg/machinery/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ type Installer[T any] interface {

// Options for the overlay installer.
type Options struct {
Name string `yaml:"name"`
KernelArgs []string `yaml:"kernelArgs,omitempty"`
PartitionOptions struct {
Offset uint64
} `yaml:"partitionOptions,omitempty"`
Name string `yaml:"name"`
KernelArgs []string `yaml:"kernelArgs,omitempty"`
PartitionOptions PartitionOptions `yaml:"partitionOptions,omitempty"`
}

// PartitionOptions for the overlay installer.
type PartitionOptions struct {
Offset uint64 `yaml:"offset,omitempty"`
}

// InstallOptions for the overlay installer.
Expand Down

0 comments on commit 952801d

Please sign in to comment.