mirror of
https://github.com/kairos-io/immucore.git
synced 2025-08-31 06:10:35 +00:00
🐛 Add missing dependency to bind mounts (#102)
As overlay mounts its responsible of mounting some of the RW paths that bind mounts are using (for example /etc) we need to depend on it and let it finish before running ht ebind mounts Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
@@ -236,6 +236,7 @@ func (s *State) MountCustomOverlayDagStep(g *herd.Graph) error {
|
||||
var multierr *multierror.Error
|
||||
internalUtils.Log.Debug().Strs("dirs", s.OverlayDirs).Msg("Mounting overlays")
|
||||
for _, p := range s.OverlayDirs {
|
||||
internalUtils.Log.Debug().Str("what", p).Msg("Overlay mount start")
|
||||
op := mountWithBaseOverlay(p, s.Rootdir, "/run/overlay")
|
||||
err := op.run()
|
||||
// Append to errors only if it's not an already mounted error
|
||||
@@ -245,6 +246,7 @@ func (s *State) MountCustomOverlayDagStep(g *herd.Graph) error {
|
||||
continue
|
||||
}
|
||||
s.fstabs = append(s.fstabs, &op.FstabEntry)
|
||||
internalUtils.Log.Debug().Str("what", p).Msg("Overlay mount done")
|
||||
}
|
||||
return multierr.ErrorOrNil()
|
||||
},
|
||||
@@ -261,6 +263,7 @@ func (s *State) MountCustomMountsDagStep(g *herd.Graph) error {
|
||||
internalUtils.Log.Debug().Interface("mounts", s.CustomMounts).Msg("Mounting custom mounts")
|
||||
|
||||
for what, where := range s.CustomMounts {
|
||||
internalUtils.Log.Debug().Str("what", what).Str("where", where).Msg("Custom mount start")
|
||||
// TODO: scan for the custom mount disk to know the underlying fs and set it proper
|
||||
fstype := "ext4"
|
||||
mountOptions := []string{"ro"}
|
||||
@@ -281,6 +284,7 @@ func (s *State) MountCustomMountsDagStep(g *herd.Graph) error {
|
||||
if err2 != nil && !strings.Contains(what, "COS_OEM") {
|
||||
err = multierror.Append(err, err2)
|
||||
}
|
||||
internalUtils.Log.Debug().Str("what", what).Str("where", where).Msg("Custom mount done")
|
||||
}
|
||||
internalUtils.Log.Err(err.ErrorOrNil()).Send()
|
||||
|
||||
@@ -293,13 +297,14 @@ func (s *State) MountCustomMountsDagStep(g *herd.Graph) error {
|
||||
// mount state is defined over a custom mount (/usr/local/.state for instance, needs to be mounted over a device).
|
||||
func (s *State) MountCustomBindsDagStep(g *herd.Graph) error {
|
||||
return g.Add(cnst.OpMountBind,
|
||||
herd.WithDeps(cnst.OpCustomMounts, cnst.OpLoadConfig),
|
||||
herd.WithDeps(cnst.OpOverlayMount, cnst.OpCustomMounts, cnst.OpLoadConfig),
|
||||
herd.WithCallback(
|
||||
func(ctx context.Context) error {
|
||||
var err *multierror.Error
|
||||
internalUtils.Log.Debug().Strs("mounts", s.BindMounts).Msg("Mounting binds")
|
||||
|
||||
for _, p := range s.BindMounts {
|
||||
internalUtils.Log.Debug().Str("what", p).Msg("Bind mount start")
|
||||
op := mountBind(p, s.Rootdir, s.StateDir)
|
||||
err2 := op.run()
|
||||
if err2 == nil {
|
||||
@@ -311,6 +316,7 @@ func (s *State) MountCustomBindsDagStep(g *herd.Graph) error {
|
||||
internalUtils.Log.Err(err2).Send()
|
||||
err = multierror.Append(err, err2)
|
||||
}
|
||||
internalUtils.Log.Debug().Str("what", p).Msg("Bind mount end")
|
||||
}
|
||||
internalUtils.Log.Err(err.ErrorOrNil()).Send()
|
||||
return err.ErrorOrNil()
|
||||
|
@@ -82,7 +82,7 @@ func checkLiveCDDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||
|
||||
}
|
||||
func checkDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||
Expect(len(dag)).To(Equal(11), actualDag)
|
||||
Expect(len(dag)).To(Equal(12), actualDag)
|
||||
Expect(len(dag[0])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[1])).To(Equal(3), actualDag)
|
||||
Expect(len(dag[2])).To(Equal(1), actualDag)
|
||||
@@ -91,9 +91,10 @@ func checkDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||
Expect(len(dag[5])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[6])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[7])).To(Equal(2), actualDag)
|
||||
Expect(len(dag[8])).To(Equal(2), actualDag)
|
||||
Expect(len(dag[8])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[9])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[10])).To(Equal(1), actualDag)
|
||||
Expect(len(dag[11])).To(Equal(1), actualDag)
|
||||
|
||||
Expect(dag[0][0].Name).To(Equal("init"))
|
||||
Expect(dag[1][0].Name).To(Or(
|
||||
@@ -118,8 +119,8 @@ func checkDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||
Expect(dag[6][0].Name).To(Equal(cnst.OpLoadConfig), actualDag)
|
||||
Expect(dag[7][0].Name).To(Or(Equal(cnst.OpMountBaseOverlay), Equal(cnst.OpCustomMounts)), actualDag)
|
||||
Expect(dag[7][1].Name).To(Or(Equal(cnst.OpMountBaseOverlay), Equal(cnst.OpCustomMounts)), actualDag)
|
||||
Expect(dag[8][0].Name).To(Or(Equal(cnst.OpMountBind), Equal(cnst.OpOverlayMount)), actualDag)
|
||||
Expect(dag[8][1].Name).To(Or(Equal(cnst.OpMountBind), Equal(cnst.OpOverlayMount)), actualDag)
|
||||
Expect(dag[9][0].Name).To(Equal(cnst.OpWriteFstab), actualDag)
|
||||
Expect(dag[10][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag)
|
||||
Expect(dag[8][0].Name).To(Equal(cnst.OpOverlayMount), actualDag)
|
||||
Expect(dag[9][0].Name).To(Equal(cnst.OpMountBind), actualDag)
|
||||
Expect(dag[10][0].Name).To(Equal(cnst.OpWriteFstab), actualDag)
|
||||
Expect(dag[11][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag)
|
||||
}
|
||||
|
Reference in New Issue
Block a user