feat: skip overlay mount checks with docker

We need to be able to run an install with `docker run`. This checks if
we are running from docker and skips overlay mount checks if we are, as
docker creates a handful of overlay mounts by default that we can't
workaround (not easily at least).

Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
This commit is contained in:
Andrew Rynhard 2021-06-21 21:27:44 +00:00 committed by talos-bot
parent b6e02311a3
commit 821f469a1d

View File

@ -94,13 +94,18 @@ func NewManifest(label string, sequence runtime.Sequence, bootPartitionFound boo
}
}
skipOverlayMountsCheck, err := shouldSkipOverlayMountsCheck(sequence)
if err != nil {
return nil, err
}
manifest.Devices[opts.Disk] = Device{
Device: opts.Disk,
ResetPartitionTable: opts.Force,
Zero: opts.Zero,
SkipOverlayMountsCheck: sequence == runtime.SequenceNoop,
SkipOverlayMountsCheck: skipOverlayMountsCheck,
}
// Initialize any slices we need. Note that a boot partition is not
@ -533,3 +538,20 @@ func (m *Manifest) zeroDevice(device Device) (err error) {
return bd.Close()
}
func shouldSkipOverlayMountsCheck(sequence runtime.Sequence) (bool, error) {
var skipOverlayMountsCheck bool
_, err := os.Stat("/.dockerenv")
switch {
case err == nil:
skipOverlayMountsCheck = true
case os.IsNotExist(err):
skipOverlayMountsCheck = sequence == runtime.SequenceNoop
default:
return false, fmt.Errorf("cannot determine if /.dockerenv exists: %w", err)
}
return skipOverlayMountsCheck, nil
}