Skip to content

Commit cf24fb0

Browse files
committed
directly copies into the root
This prevents running out of space if there are too many changes.
1 parent 8b383a8 commit cf24fb0

File tree

2 files changed

+5
-53
lines changed

2 files changed

+5
-53
lines changed

core/oci.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import (
2424
"time"
2525

2626
"github.com/containers/buildah"
27-
"go.podman.io/image/v5/types"
28-
"go.podman.io/storage"
2927
humanize "github.com/dustin/go-humanize"
3028
digest "github.com/opencontainers/go-digest"
3129
"github.com/pterm/pterm"
3230
"github.com/vanilla-os/abroot/settings"
3331
"github.com/vanilla-os/prometheus"
32+
"go.podman.io/image/v5/types"
33+
"go.podman.io/storage"
3434
)
3535

3636
type NotEnoughSpaceError struct{}
@@ -152,7 +152,7 @@ func OciExportRootFs(buildImageName string, imageRecipe *ImageRecipe, transDir s
152152
}
153153

154154
// copy mount dir contents to dest
155-
err = rsyncCmd(mountDir+"/", dest, []string{"--delete", "--checksum"}, false)
155+
err = rsyncCmd(mountDir+"/", dest, []string{"--delete", "--delete-before", "--checksum"}, false)
156156
if err != nil {
157157
PrintVerboseErr("OciExportRootFs", 9, err)
158158
return err

core/system.go

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"errors"
1818
"fmt"
1919
"os"
20-
"os/exec"
2120
"path/filepath"
2221
"strconv"
2322
"strings"
@@ -285,8 +284,7 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation, freeSpace bool) err
285284
return err
286285
}
287286

288-
systemNew := filepath.Join(partFuture.Partition.MountPoint, "new")
289-
os.RemoveAll(systemNew) // errors are safe to ignore
287+
systemNew := filepath.Join(partFuture.Partition.MountPoint)
290288

291289
cq.Add(func(args ...interface{}) error {
292290
return partFuture.Partition.Unmount()
@@ -376,14 +374,6 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation, freeSpace bool) err
376374
PrintVerboseErr("ABSystem.RunOperation", 4, err)
377375
return err
378376
}
379-
} else {
380-
PrintVerboseInfo("ABSystemRunOperation", "Creating a reflink clone of the old system to copy into")
381-
err = exec.Command("cp", "--reflink", "-a", partFuture.Partition.MountPoint, systemNew).Run()
382-
if err != nil {
383-
PrintVerboseWarn("ABSystem.RunOperation", 4.1, "reflink copy of system failed, falling back to slow copy because:", err)
384-
// can be safely ignored
385-
// file system doesn't support CoW
386-
}
387377
}
388378

389379
abrootTrans := filepath.Join(partFuture.Partition.MountPoint, "abroot-trans")
@@ -468,11 +458,6 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation, freeSpace bool) err
468458
return err
469459
}
470460

471-
// from this point on, it is not possible to stop the upgrade
472-
// so we create the finalizing file. Note that interrupting the upgrade
473-
// from this point on will not leave the system in an inconsistent
474-
// state, but it could leave the future partition in a dirty state
475-
// preventing it from booting.
476461
err = s.createFinalizingFile()
477462
if err != nil {
478463
PrintVerboseErr("ABSystem.RunOperation", 5.3, err)
@@ -654,43 +639,10 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation, freeSpace bool) err
654639
return partBoot.Unmount()
655640
}, nil, 100, &goodies.NoErrorHandler{}, false)
656641

657-
// Stage 9: Apply the new rootfs
642+
// Stage 9: Atomic swap the bootloader
658643
// ------------------------------------------------
659644
PrintVerboseSimple("[Stage 9] -------- ABSystemRunOperation")
660645

661-
err = ClearDirectory(partFuture.Partition.MountPoint, []string{"new"})
662-
if err != nil {
663-
PrintVerboseErr("ABSystem.RunOperation", 10.1, err)
664-
return err
665-
}
666-
667-
files, err := os.ReadDir(systemNew)
668-
if err != nil {
669-
PrintVerboseErr("ABSystem.RunOperation", 10.2, err)
670-
return err
671-
}
672-
673-
// Move everything from /part-future/new to /part-future
674-
for _, file := range files {
675-
srcPath := filepath.Join(systemNew, file.Name())
676-
dstPath := filepath.Join(partFuture.Partition.MountPoint, file.Name())
677-
err = os.Rename(srcPath, dstPath)
678-
if err != nil {
679-
PrintVerboseErr("ABSystem.RunOperation", 10.3, err)
680-
return err
681-
}
682-
}
683-
684-
err = os.RemoveAll(systemNew)
685-
if err != nil {
686-
PrintVerboseErr("ABSystem.RunOperation", 10.4, err)
687-
return err
688-
}
689-
690-
// Stage 10: Atomic swap the bootloader
691-
// ------------------------------------------------
692-
PrintVerboseSimple("[Stage 10] -------- ABSystemRunOperation")
693-
694646
grub, err := NewGrub(partBoot)
695647
if err != nil {
696648
PrintVerboseErr("ABSystem.RunOperation", 11, err)

0 commit comments

Comments
 (0)