diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-10-28 01:27:29 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-28 01:27:29 +0000 |
commit | caf0b57f781e04ab7332049701ea7611254d58d7 (patch) | |
tree | 0178a1b25321c29a033c5e58378f0524d82db012 /runsc | |
parent | dccef20b3b64e3d48febab46b06d207a8b85e92f (diff) | |
parent | d350c95b04d594abedaad1846f35304b55194e84 (diff) |
Merge release-20211019.0-50-gd350c95b0 (automated)
Diffstat (limited to 'runsc')
-rw-r--r-- | runsc/cgroup/cgroup.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/runsc/cgroup/cgroup.go b/runsc/cgroup/cgroup.go index 7a0f0694f..fdcaed4ea 100644 --- a/runsc/cgroup/cgroup.go +++ b/runsc/cgroup/cgroup.go @@ -30,10 +30,10 @@ import ( "github.com/cenkalti/backoff" specs "github.com/opencontainers/runtime-spec/specs-go" + "golang.org/x/sync/errgroup" "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/cleanup" "gvisor.dev/gvisor/pkg/log" - "gvisor.dev/gvisor/pkg/sync" ) const ( @@ -412,7 +412,7 @@ func (c *Cgroup) createController(name string) (bool, error) { // existed when Install() was called, Uninstall is a noop. func (c *Cgroup) Uninstall() error { log.Debugf("Deleting cgroup %q", c.Name) - wait := sync.WaitGroupErr{} + g, ctx := errgroup.WithContext(context.Background()) for key := range controllers { if !c.Own[key] { // cgroup is managed by caller, don't touch it. @@ -423,7 +423,7 @@ func (c *Cgroup) Uninstall() error { // If we try to remove the cgroup too soon after killing the sandbox we // might get EBUSY, so we retry for a few seconds until it succeeds. - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() b := backoff.WithContext(backoff.NewConstantBackOff(100*time.Millisecond), ctx) fn := func() error { @@ -435,16 +435,14 @@ func (c *Cgroup) Uninstall() error { } // Run deletions in parallel to remove all directories even if there are // failures/timeouts in other directories. - wait.Add(1) - go func() { - defer wait.Done() + g.Go(func() error { if err := backoff.Retry(fn, b); err != nil { - wait.ReportError(fmt.Errorf("removing cgroup path %q: %w", path, err)) - return + return fmt.Errorf("removing cgroup path %q: %w", path, err) } - }() + return nil + }) } - return wait.Error() + return g.Wait() } // Join adds the current process to the all controllers. Returns function that |