Skip to content

Commit

Permalink
Merge pull request #1926 from rudyfly/volume
Browse files Browse the repository at this point in the history
bugfix: don't set mount tab when rootfs diskquota is null
  • Loading branch information
CodeJuan authored Jul 30, 2018
2 parents 7df653e + f6198aa commit 459618b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions daemon/mgr/spec_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ func setupHook(ctx context.Context, c *Container, specWrapper *SpecWrapper) erro
}

// setup diskquota hook, if rootFSQuota not set skip this part.
if err := setRootfsDiskQuota(ctx, c, specWrapper); err != nil {
return errors.Wrap(err, "failed to set rootfs disk")
}

// set volume mount tab
if err := setMountTab(ctx, c, specWrapper); err != nil {
return errors.Wrap(err, "failed to set volume mount tab prestart hook")
}

return nil
}

func setRootfsDiskQuota(ctx context.Context, c *Container, spec *SpecWrapper) error {
rootFSQuota := quota.GetDefaultQuota(c.Config.DiskQuota)
if rootFSQuota == "" {
return nil
Expand All @@ -70,16 +83,11 @@ func setupHook(ctx context.Context, c *Container, specWrapper *SpecWrapper) erro
return err
}

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

// set volume mount tab
if err := setMountTab(ctx, c, specWrapper); err != nil {
return errors.Wrap(err, "failed to set volume mount tab prestart hook")
}

return nil
}

Expand Down

0 comments on commit 459618b

Please sign in to comment.