Skip to content

Commit

Permalink
Merge pull request #1136 from rudyfly/diskquota
Browse files Browse the repository at this point in the history
bugfix: fix set diskquota failed without quota id
  • Loading branch information
allencloud authored Apr 17, 2018
2 parents 9fff714 + 38d66a6 commit 70b1674
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions daemon/mgr/spec_blkio.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"syscall"

"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/pkg/quota"
specs "github.com/opencontainers/runtime-spec/specs-go"
)

Expand Down Expand Up @@ -95,13 +96,14 @@ func getThrottleDevice(devs []*types.ThrottleDevice) ([]specs.LinuxThrottleDevic
func setupDiskQuota(ctx context.Context, meta *ContainerMeta, spec *SpecWrapper) error {
s := spec.s

rootFSQuota, ok := meta.Config.DiskQuota["/"]
if !ok || rootFSQuota == "" {
commonQuota, ok := meta.Config.DiskQuota[".*"]
if !ok || commonQuota == "" {
return nil
}
rootFSQuota = commonQuota
rootFSQuota := quota.GetDefaultQuota(meta.Config.DiskQuota)
if rootFSQuota == "" {
return nil
}

qid := "0"
if meta.Config.QuotaID != "" {
qid = meta.Config.QuotaID
}

if s.Hooks == nil {
Expand All @@ -118,7 +120,7 @@ func setupDiskQuota(ctx context.Context, meta *ContainerMeta, spec *SpecWrapper)

quotaPrestart := specs.Hook{
Path: target,
Args: []string{"set-diskquota", meta.BaseFS, rootFSQuota, meta.Config.QuotaID},
Args: []string{"set-diskquota", meta.BaseFS, rootFSQuota, qid},
}
s.Hooks.Prestart = append(s.Hooks.Prestart, quotaPrestart)

Expand Down

0 comments on commit 70b1674

Please sign in to comment.