mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
enhance storage-opt validation logic in overlay2 driver
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
This commit is contained in:
parent
9c71a2be31
commit
e9d785ce3f
1 changed files with 9 additions and 9 deletions
|
@ -300,23 +300,23 @@ func (d *Driver) Cleanup() error {
|
|||
// CreateReadWrite creates a layer that is writable for use as a container
|
||||
// file system.
|
||||
func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts) error {
|
||||
if opts != nil && len(opts.StorageOpt) != 0 && !projectQuotaSupported {
|
||||
return fmt.Errorf("--storage-opt is supported only for overlay over xfs with 'pquota' mount option")
|
||||
}
|
||||
|
||||
if opts == nil {
|
||||
opts = &graphdriver.CreateOpts{
|
||||
StorageOpt: map[string]string{},
|
||||
StorageOpt: make(map[string]string),
|
||||
}
|
||||
} else if opts.StorageOpt == nil {
|
||||
opts.StorageOpt = make(map[string]string)
|
||||
}
|
||||
|
||||
if _, ok := opts.StorageOpt["size"]; !ok {
|
||||
if opts.StorageOpt == nil {
|
||||
opts.StorageOpt = map[string]string{}
|
||||
}
|
||||
// Merge daemon default config.
|
||||
if _, ok := opts.StorageOpt["size"]; !ok && d.options.quota.Size != 0 {
|
||||
opts.StorageOpt["size"] = strconv.FormatUint(d.options.quota.Size, 10)
|
||||
}
|
||||
|
||||
if _, ok := opts.StorageOpt["size"]; ok && !projectQuotaSupported {
|
||||
return fmt.Errorf("--storage-opt is supported only for overlay over xfs with 'pquota' mount option")
|
||||
}
|
||||
|
||||
return d.create(id, parent, opts)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue