Skip to content

Commit

Permalink
fix: don't probe disks in container mode
Browse files Browse the repository at this point in the history
There's no system disk or meta in container mode, and `/sys/block` gets
_host_ block devices, so we better skip these probes altogether.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Jan 29, 2021
1 parent 1051d2a commit 064d332
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type State struct {

// MachineState represents the machine's state.
type MachineState struct {
platform runtime.Platform

disks map[string]*probe.ProbedBlockDevice

stagedInstall bool
Expand All @@ -48,7 +50,9 @@ func NewState() (s *State, err error) {
return nil, err
}

machine := &MachineState{}
machine := &MachineState{
platform: p,
}

err = machine.probeDisks()
if err != nil {
Expand Down Expand Up @@ -97,6 +101,10 @@ func (s *State) V1Alpha2() runtime.V1Alpha2State {
}

func (s *MachineState) probeDisks(labels ...string) error {
if s.platform.Mode() == runtime.ModeContainer {
return os.ErrNotExist
}

if len(labels) == 0 {
labels = []string{constants.EphemeralPartitionLabel, constants.BootPartitionLabel, constants.EFIPartitionLabel, constants.StatePartitionLabel}
}
Expand Down Expand Up @@ -124,6 +132,10 @@ func (s *MachineState) probeDisks(labels ...string) error {
}

func (s *MachineState) probeMeta() {
if s.platform.Mode() == runtime.ModeContainer {
return
}

meta, err := bootloader.NewMeta()
if err != nil {
// ignore missing meta
Expand Down

0 comments on commit 064d332

Please sign in to comment.