Skip to content

Commit

Permalink
Merge pull request #37867 from mountkin/fix-ov2
Browse files Browse the repository at this point in the history
enhance storage-opt validation logic in overlay2 driver
Upstream-commit: 55e6d7d36fafcfbd5c97b019a1652f63231ebcf5
Component: engine
  • Loading branch information
AkihiroSuda authored Apr 19, 2020
2 parents 02bca95 + ddb5fb1 commit b078746
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/engine/daemon/graphdriver/overlay2/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit b078746

Please sign in to comment.