MCPcopy
hub / github.com/dgraph-io/dgraph / destroyContainers

Method destroyContainers

dgraphtest/local_cluster.go:346–382  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

344}
345
346func (c *LocalCluster) destroyContainers() error {
347 ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
348 defer cancel()
349
350 var wg sync.WaitGroup
351 errChan := make(chan error, len(c.zeros)+len(c.alphas))
352 ro := container.RemoveOptions{RemoveVolumes: true, Force: true}
353
354 for _, zo := range c.zeros {
355 wg.Add(1)
356 go func(z *zero) {
357 defer wg.Done()
358 if err := c.dcli.ContainerRemove(ctx, z.cid(), ro); err != nil && !cerrdefs.IsNotFound(err) {
359 errChan <- errors.Wrapf(err, "error removing zero [%v]", z.cname())
360 }
361 }(zo)
362 }
363
364 for _, aa := range c.alphas {
365 wg.Add(1)
366 go func(a *alpha) {
367 defer wg.Done()
368 if err := c.dcli.ContainerRemove(ctx, a.cid(), ro); err != nil && !cerrdefs.IsNotFound(err) {
369 errChan <- errors.Wrapf(err, "error removing alpha [%v]", a.cname())
370 }
371 }(aa)
372 }
373
374 wg.Wait()
375 close(errChan)
376
377 for err := range errChan {
378 return err
379 }
380
381 return nil
382}
383
384func (c *LocalCluster) printPortMappings() error {
385 containers, err := c.dcli.ContainerList(context.Background(), container.ListOptions{})

Callers 2

CleanupMethod · 0.95
recreateContainersMethod · 0.95

Calls 5

WaitMethod · 0.80
cidMethod · 0.65
cnameMethod · 0.65
AddMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected