Skip to content

Commit 006839b

Browse files
committed
storage: improve error message on image mount from r/o store
Signed-off-by: Michele Comignano <mcdev@playlinux.net>
1 parent 5af159b commit 006839b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

storage/store.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,17 @@ func (s *store) MountImage(id string, mountOpts []string, mountLabel string) (st
30403040
MountLabel: mountLabel,
30413041
Options: append(mountOpts, "ro"),
30423042
}
3043-
return rlstore.Mount(ilayer.ID, options)
3043+
if rlstore.Exists(ilayer.ID) {
3044+
return rlstore.Mount(ilayer.ID, options)
3045+
}
3046+
// check if the layer is in a read-only store, and return a better error message
3047+
for _, store := range lstores {
3048+
// required read lock is acquired earlier in this function
3049+
if store.Exists(ilayer.ID) {
3050+
return "", fmt.Errorf("mounting read/only store images is not allowed: %w", ErrStoreIsReadOnly)
3051+
}
3052+
}
3053+
return "", ErrLayerUnknown
30443054
}
30453055

30463056
func (s *store) Mount(id, mountLabel string) (string, error) {

0 commit comments

Comments
 (0)