diff --git a/go.mod b/go.mod index 3e811bf..e3fe7ad 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/onsi/ginkgo/v2 v2.9.0 github.com/onsi/gomega v1.27.2 github.com/rs/zerolog v1.29.0 + github.com/sirupsen/logrus v1.8.1 github.com/spectrocloud-labs/herd v0.4.2 github.com/twpayne/go-vfs v1.7.2 github.com/urfave/cli/v2 v2.25.0 @@ -93,7 +94,6 @@ require ( github.com/satori/go.uuid v1.2.1-0.20180404165556-75cca531ea76 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/tredoe/osutil/v2 v2.0.0-rc.16 // indirect github.com/ulikunitz/xz v0.5.10 // indirect diff --git a/go.sum b/go.sum index 8dac00c..c64ae50 100644 --- a/go.sum +++ b/go.sum @@ -667,8 +667,6 @@ github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= -github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= github.com/onsi/ginkgo/v2 v2.9.0 h1:Tugw2BKlNHTMfG+CheOITkYvk4LAh6MFOvikhGVnhE8= github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= @@ -884,11 +882,9 @@ github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= -github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= -github.com/vishvananda/netlink v0.0.0-20170808154308-f5a6f697a596/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8= github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/vishvananda/netlink v0.0.0-20170808154308-f5a6f697a596/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= diff --git a/internal/utils/mounts.go b/internal/utils/mounts.go index a9134f2..3249f6d 100644 --- a/internal/utils/mounts.go +++ b/internal/utils/mounts.go @@ -258,6 +258,7 @@ func GetOemLabel() string { runtime, err := state.NewRuntime() if err != nil { Log.Debug().Err(err).Msg("runtime") + return "" } return runtime.OEM.Label } diff --git a/main.go b/main.go index 2de5fb8..079702f 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,6 @@ func main() { TargetDevice: targetDevice, TargetImage: targetImage, RootMountMode: utils.RootRW(), - OemTimout: utils.GetOemTimeout(), OverlayBase: utils.GetOverlayBase(), } diff --git a/pkg/mount/dag_steps.go b/pkg/mount/dag_steps.go index 590930d..a935956 100644 --- a/pkg/mount/dag_steps.go +++ b/pkg/mount/dag_steps.go @@ -176,6 +176,10 @@ func (s *State) LoadEnvLayoutDagStep(g *herd.Graph, deps ...string) error { func (s *State) MountOemDagStep(g *herd.Graph, deps ...string) error { return g.Add(cnst.OpMountOEM, herd.WithDeps(deps...), + herd.EnableIf(func() bool { + // Check if we can get the label. If we cant then we don't run this step + return internalUtils.GetOemLabel() != "" + }), herd.WithCallback( s.MountOP( fmt.Sprintf("/dev/disk/by-label/%s", internalUtils.GetOemLabel()), @@ -187,7 +191,7 @@ func (s *State) MountOemDagStep(g *herd.Graph, deps ...string) error { "dev", "exec", "async", - }, time.Duration(s.OemTimout)*time.Second), + }, time.Duration(internalUtils.GetOemTimeout())*time.Second), ), ) } diff --git a/pkg/mount/state.go b/pkg/mount/state.go index 165a468..822d117 100644 --- a/pkg/mount/state.go +++ b/pkg/mount/state.go @@ -26,12 +26,9 @@ type State struct { OverlayDirs []string // e.g. /var BindMounts []string // e.g. /etc/kubernetes CustomMounts map[string]string // e.g. diskid : mountpoint - - OverlayBase string // Overlay config, defaults to tmpfs:20% - OemTimout int // Time to wait for the oem to time out if not found, defaults to 5s - - StateDir string // e.g. "/usr/local/.state" - fstabs []*fstab.Mount + OverlayBase string // Overlay config, defaults to tmpfs:20% + StateDir string // e.g. "/usr/local/.state" + fstabs []*fstab.Mount } func (s *State) path(p ...string) string {