Fix container storage to support additional image stores
We want to support additional read/only image stores available on file systems. Usually these images stores would be on network shares. Currently the only driver that will support additional images is the overlay file system. Signed-off-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
9ca0966e36
commit
1624d9622b
|
|
@ -372,6 +372,12 @@ func (a *Driver) Diff(id, parent string) (archive.Archive, error) {
|
|||
})
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (a *Driver) AdditionalImageStores() []string {
|
||||
var imageStores []string
|
||||
return imageStores
|
||||
}
|
||||
|
||||
type fileGetNilCloser struct {
|
||||
storage.FileGetter
|
||||
}
|
||||
|
|
|
|||
|
|
@ -518,3 +518,9 @@ func (d *Driver) Exists(id string) bool {
|
|||
_, err := os.Stat(dir)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (d *Driver) AdditionalImageStores() []string {
|
||||
var imageStores []string
|
||||
return imageStores
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,3 +224,9 @@ func (d *Driver) Put(id string) error {
|
|||
func (d *Driver) Exists(id string) bool {
|
||||
return d.DeviceSet.HasDevice(id)
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (d *Driver) AdditionalImageStores() []string {
|
||||
var imageStores []string
|
||||
return imageStores
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ type ProtoDriver interface {
|
|||
// held by the driver, e.g., unmounting all layered filesystems
|
||||
// known to this driver.
|
||||
Cleanup() error
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
AdditionalImageStores() []string
|
||||
}
|
||||
|
||||
// Driver is the interface for layered/snapshot file system drivers.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
|
@ -82,6 +83,7 @@ type Driver struct {
|
|||
uidMaps []idtools.IDMap
|
||||
gidMaps []idtools.IDMap
|
||||
ctr *graphdriver.RefCounter
|
||||
opts *overlayOptions
|
||||
}
|
||||
|
||||
var backingFs = "<unknown>"
|
||||
|
|
@ -149,6 +151,7 @@ func InitWithName(name, home string, options []string, uidMaps, gidMaps []idtool
|
|||
uidMaps: uidMaps,
|
||||
gidMaps: gidMaps,
|
||||
ctr: graphdriver.NewRefCounter(graphdriver.NewFsChecker(graphdriver.FsMagicOverlay)),
|
||||
opts: opts,
|
||||
}
|
||||
|
||||
return d, nil
|
||||
|
|
@ -170,6 +173,7 @@ func InitAsOverlay2(home string, options []string, uidMaps, gidMaps []idtools.ID
|
|||
|
||||
type overlayOptions struct {
|
||||
overrideKernelCheck bool
|
||||
imageStores []string
|
||||
}
|
||||
|
||||
func parseOptions(options []string) (*overlayOptions, error) {
|
||||
|
|
@ -186,6 +190,22 @@ func parseOptions(options []string) (*overlayOptions, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "overlay.imagestore":
|
||||
// Additional read only image stores to use for lower paths
|
||||
for _, store := range strings.Split(val, ",") {
|
||||
store = filepath.Clean(store)
|
||||
if !filepath.IsAbs(store) {
|
||||
return nil, fmt.Errorf("overlay: image path %q is not absolute. Can not be relative", store)
|
||||
}
|
||||
st, err := os.Stat(store)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("overlay: Can't stat imageStore dir %s: %v", store, err)
|
||||
}
|
||||
if !st.IsDir() {
|
||||
return nil, fmt.Errorf("overlay: image path %q must be a directory", store)
|
||||
}
|
||||
o.imageStores = append(o.imageStores, store)
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("overlay: Unknown option %s", key)
|
||||
}
|
||||
|
|
@ -527,3 +547,8 @@ func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
|
|||
|
||||
return archive.OverlayChanges(layers, diffPath)
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (d *Driver) AdditionalImageStores() []string {
|
||||
return d.opts.imageStores
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,3 +143,9 @@ func (d *Driver) Exists(id string) bool {
|
|||
_, err := os.Stat(d.dir(id))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (d *Driver) AdditionalImageStores() []string {
|
||||
var imageStores []string
|
||||
return imageStores
|
||||
}
|
||||
|
|
|
|||
|
|
@ -403,3 +403,9 @@ func (d *Driver) Exists(id string) bool {
|
|||
defer d.Unlock()
|
||||
return d.filesystemsCache[d.zfsPath(id)] == true
|
||||
}
|
||||
|
||||
// AdditionalImageStores returns additional image stores supported by the driver
|
||||
func (d *Driver) AdditionalImageStores() []string {
|
||||
var imageStores []string
|
||||
return imageStores
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue