Skip to content

Commit e2dee41

Browse files
authored
Merge pull request #945 from comick/betterlog
storage: improve error message on image mount from r/o store
2 parents 79b0a6d + 006839b commit e2dee41

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
@@ -3066,7 +3066,17 @@ func (s *store) MountImage(id string, mountOpts []string, mountLabel string) (st
30663066
MountLabel: mountLabel,
30673067
Options: append(mountOpts, "ro"),
30683068
}
3069-
return rlstore.Mount(ilayer.ID, options)
3069+
if rlstore.Exists(ilayer.ID) {
3070+
return rlstore.Mount(ilayer.ID, options)
3071+
}
3072+
// check if the layer is in a read-only store, and return a better error message
3073+
for _, store := range lstores {
3074+
// required read lock is acquired earlier in this function
3075+
if store.Exists(ilayer.ID) {
3076+
return "", fmt.Errorf("mounting read/only store images is not allowed: %w", ErrStoreIsReadOnly)
3077+
}
3078+
}
3079+
return "", ErrLayerUnknown
30703080
}
30713081

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

0 commit comments

Comments
 (0)