@@ -35,7 +35,7 @@ func RunMigration(cfg common.Config) (*storage.Image, error) {
3535 if err != nil { return nil , err }
3636 defer cleanupSrcStore ()
3737
38- scratchStore , cleanupScratch , err := setupScratchStore (cfg )
38+ scratchStore , cleanupScratch , err := setupScratchStore (& cfg )
3939 if err != nil { return nil , err }
4040 defer cleanupScratch ()
4141
@@ -209,9 +209,19 @@ func setupSrcStore(cfg common.Config) (storage.Store, func(), error) {
209209 return srcStore , cleanup , nil
210210}
211211
212- func setupScratchStore (cfg common.Config ) (storage.Store , func (), error ) {
212+ 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
216+ mirror , mirrorCleanup , err := common .Mirror (cfg .RoStoragePath )
217+ if err != nil {
218+ sublog .Debug ("Failed to mount mirror: %v" , err )
219+ return nil , nil , err
220+ }
221+ sublog .Infof ("Mounted mirror of %s at %s" , cfg .RoStoragePath , mirror )
222+ originalPath := cfg .RoStoragePath
223+ cfg .RoStoragePath = mirror
224+
215225 sublog .Info ("Setting up scratch Store" )
216226 scratchRun , cleanupScratch := common .MustTempDir ("scratch-runroot-*" )
217227 scratchStore , err := storage .GetStore (storage.StoreOptions {
@@ -224,8 +234,10 @@ func setupScratchStore(cfg common.Config) (storage.Store, func(), error) {
224234 return nil , nil , err
225235 }
226236 cleanup := func () {
237+ cfg .RoStoragePath = originalPath
227238 scratchStore .Shutdown (false )
228239 cleanupScratch ()
240+ mirrorCleanup ()
229241 }
230242 return scratchStore , cleanup , nil
231243}
@@ -304,6 +316,8 @@ func putFlattenedLayer(store storage.Store, dummyDir string, digest godigest.Dig
304316}
305317
306318func readOverlayLink (layer * storage.Layer , cfg common.Config ) (string , error ) {
319+ sublog := log .WithField ("fn" , "readOverlayLink" )
320+ sublog .Infof ("Reading overlay link from %s" , cfg .RoStoragePath )
307321 linkBytes , err := os .ReadFile (filepath .Join (cfg .RoStoragePath , "overlay" , layer .ID , "link" ))
308322 if err != nil {
309323 return "" , fmt .Errorf ("read overlay link: %w" , err )
0 commit comments