Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: set container env failed Invalid cross-device link #1260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions daemon/mgr/spec_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ func setupHook(ctx context.Context, c *ContainerMeta, specWrapper *SpecWrapper)

// setup diskquota hook, if rootFSQuota not set skip this part.
rootFSQuota := quota.GetDefaultQuota(c.Config.DiskQuota)
if rootFSQuota != "" {
qid := "0"
if c.Config.QuotaID != "" {
qid = c.Config.QuotaID
}
if rootFSQuota == "" {
return nil
}

target, err := os.Readlink(filepath.Join("/proc", strconv.Itoa(os.Getpid()), "exe"))
if err != nil {
return err
}
qid := "0"
if c.Config.QuotaID != "" {
qid = c.Config.QuotaID
}

s.Hooks.Prestart = append(s.Hooks.Prestart, specs.Hook{
Path: target,
Args: []string{"set-diskquota", c.BaseFS, rootFSQuota, qid},
})
target, err := os.Readlink(filepath.Join("/proc", strconv.Itoa(os.Getpid()), "exe"))
if err != nil {
return err
}

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

return nil
}

Expand Down
7 changes: 4 additions & 3 deletions storage/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,13 @@ func SetRootfsDiskQuota(basefs, size string, quotaID uint32) error {
return fmt.Errorf("failed to set subtree: %v", err)
}

err = SetDiskQuota(dir, size, quotaID)
if err != nil {
if err := SetDiskQuota(dir, size, quotaID); err != nil {
return fmt.Errorf("failed to set disk quota: %v", err)
}

return setQuotaForDir(dir, quotaID)
if err := setQuotaForDir(dir, quotaID); err != nil {
return fmt.Errorf("failed to set dir quota: %v", err)
}
}

return nil
Expand Down