Skip to content

Commit

Permalink
pass context to manager.Run
Browse files Browse the repository at this point in the history
  • Loading branch information
nklaassen committed Apr 30, 2024
1 parent 752efb3 commit bd00c44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/vnet/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Run(ctx context.Context) error {
return trace.Wrap(err)
}

manager, err := NewManager(ctx, &Config{
manager, err := NewManager(&Config{
TUNDevice: tun,
IPv6Prefix: ipv6Prefix,
})
Expand All @@ -47,10 +47,12 @@ func Run(ctx context.Context) error {
}

g, ctx := errgroup.WithContext(ctx)
g.Go(manager.Run)
g.Go(func() error { return trace.Wrap(manager.Run(ctx)) })
g.Go(func() error {
<-ctx.Done()
return trace.Wrap(manager.Destroy())
tunErr := tun.Close()
destroyErr := manager.Destroy()
return trace.NewAggregate(tunErr, destroyErr)
})
return trace.Wrap(g.Wait())
}
Expand Down

0 comments on commit bd00c44

Please sign in to comment.