Skip to content

Commit

Permalink
bugfix: /etc/mtab will miss quota id
Browse files Browse the repository at this point in the history
if set `/etc/mtab` before set rootfs quota, it will make /etc/mtab miss
quota id of rootfs quota, so it need be moved after set rootfs quota.

with overlay work dir, it disappear `work/work`, when only set the dir
`work`'s quota id, if we remove set dir quota id by recursively, the
quota id for overlay is invalid.

Signed-off-by: Rudy Zhang <[email protected]>
  • Loading branch information
rudyfly authored and fuweid committed Jan 21, 2019
1 parent 60c8bc7 commit 554b734
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions daemon/mgr/container_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ func (mgr *ContainerManager) generateMountPoints(ctx context.Context, c *Contain
return errors.Wrap(err, "failed to populate volumes")
}

// set volumes into /etc/mtab in container
err = mgr.setMountTab(ctx, c)
if err != nil {
return errors.Wrap(err, "failed to set mount tab")
}

return nil
}

Expand Down Expand Up @@ -703,6 +697,11 @@ func (mgr *ContainerManager) initContainerStorage(ctx context.Context, c *Contai
logrus.Warnf("failed to set rootfs disk quota, err(%v)", err)
}

// set volumes into /etc/mtab in container
if err = mgr.setMountTab(ctx, c); err != nil {
return errors.Wrap(err, "failed to set mount tab")
}

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions storage/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func SetRootfsDiskQuota(basefs, size string, quotaID uint32) (uint32, error) {
if err := SetDiskQuota(dir, size, quotaID); err != nil {
return 0, errors.Wrapf(err, "failed to set dir(%s) disk quota", dir)
}

if err := SetQuotaForDir(dir, quotaID); err != nil {
return 0, errors.Wrapf(err, "failed to set dir(%s) quota recursively", dir)
}
}

return quotaID, nil
Expand Down

0 comments on commit 554b734

Please sign in to comment.