Skip to content

Commit 23f3ee8

Browse files
authored
Merge pull request #4 from sarus-suite/rsync-mirror
Rsync mirror
2 parents 5254a12 + 011d685 commit 23f3ee8

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cmd/migration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ func setupSrcStore(cfg common.Config) (storage.Store, func(), error) {
212212
func setupScratchStore(cfg *common.Config) (storage.Store, func(), error) {
213213
sublog := log.WithField("fn", "setupScratchStore")
214214

215-
// we mirror the RoStoragePath to hide the fact that might be a networkedFS
215+
// we copy mirror the RoStoragePath to hide the fact that might be a networkedFS
216216
mirror, mirrorCleanup, err := common.Mirror(cfg.RoStoragePath)
217217
if err != nil {
218-
sublog.Debug("Failed to mount mirror: %v", err)
218+
sublog.Debug("Failed to copy mirror: %v", err)
219219
return nil, nil, err
220220
}
221-
sublog.Infof("Mounted mirror of %s at %s", cfg.RoStoragePath, mirror)
221+
sublog.Infof("Copy mirror of %s at %s", cfg.RoStoragePath, mirror)
222222
originalPath := cfg.RoStoragePath
223223
cfg.RoStoragePath = mirror
224224

cmd/rmi.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ func RunRmi(cfg common.Config) error {
2424
log.Infof("Starting removal of image: %s", cfg.Image)
2525
log.Debugf("Podman Root: %s, Read-only Storage Path: %s", cfg.PodmanRoot, cfg.RoStoragePath)
2626

27+
// we copy mirror the RoStoragePath to hide the fact that might be a networkedFS
28+
mirror, mirrorCleanup, err := common.Mirror(cfg.RoStoragePath)
29+
if err != nil {
30+
log.Debug("Failed to copy mirror: %v", err)
31+
return err
32+
}
33+
log.Infof("Copy mirror of %s at %s", cfg.RoStoragePath, mirror)
34+
originalPath := cfg.RoStoragePath
35+
cfg.RoStoragePath = mirror
36+
2737
storeRun, cleanupRun := common.MustTempDir("rmi-RoStore-*")
2838
log.Infof("Opened store with: %s, %s", cfg.RoStoragePath, storeRun)
2939
store, err := storage.GetStore(storage.StoreOptions{
@@ -35,8 +45,10 @@ func RunRmi(cfg common.Config) error {
3545
panic(fmt.Errorf("Error init overlay store: %w", err))
3646
}
3747
defer func() {
48+
cfg.RoStoragePath = originalPath
3849
store.Shutdown(false)
3950
cleanupRun()
51+
mirrorCleanup()
4052
log.Info("Teardown of store completed")
4153
}()
4254

0 commit comments

Comments
 (0)