Skip to content

Commit

Permalink
test: provide a way to force different boot order in provision library
Browse files Browse the repository at this point in the history
There's no change to the default behavior. This change is going to be
used with Sidero/Sfyra.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed May 18, 2021
1 parent a1c0e99 commit 8280441
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/provision/providers/qemu/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type LaunchConfig struct {
KernelArgs string
MachineType string
MonitorPath string
DefaultBootOrder string
EnableKVM bool
BootloaderEnabled bool
NodeUUID uuid.UUID
Expand Down Expand Up @@ -220,7 +221,7 @@ func checkPartitions(config *LaunchConfig) (bool, error) {
//
//nolint:gocyclo
func launchVM(config *LaunchConfig) error {
bootOrder := "cn"
bootOrder := config.DefaultBootOrder

if config.controller.ForcePXEBoot() {
bootOrder = "nc"
Expand Down
6 changes: 6 additions & 0 deletions pkg/provision/providers/qemu/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (p *provisioner) createNode(state *vm.State, clusterReq provision.ClusterRe
return provision.NodeInfo{}, fmt.Errorf("error finding listen address for the API: %w", err)
}

defaultBootOrder := "cn"
if nodeReq.DefaultBootOrder != "" {
defaultBootOrder = nodeReq.DefaultBootOrder
}

launchConfig := LaunchConfig{
QemuExecutable: arch.QemuExecutable(),
DiskPaths: diskPaths,
Expand All @@ -110,6 +115,7 @@ func (p *provisioner) createNode(state *vm.State, clusterReq provision.ClusterRe
PFlashImages: pflashImages,
MonitorPath: state.GetRelativePath(fmt.Sprintf("%s.monitor", nodeReq.Name)),
EnableKVM: opts.TargetArch == runtime.GOARCH,
DefaultBootOrder: defaultBootOrder,
BootloaderEnabled: opts.BootloaderEnabled,
NodeUUID: nodeUUID,
Config: nodeConfig,
Expand Down
4 changes: 4 additions & 0 deletions pkg/provision/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ type NodeRequest struct {
Ports []string
// SkipInjectingConfig disables reading configuration from http server
SkipInjectingConfig bool
// DefaultBootOrder overrides default boot order "cn" (disk, then network boot).
//
// BootOrder can be forced to be "nc" (PXE boot) via the API in QEMU provisioner.
DefaultBootOrder string

// PXE-booted VMs
PXEBooted bool
Expand Down

0 comments on commit 8280441

Please sign in to comment.