fix: Unify context usage for agent cmd and logs (#5059)

This commit is contained in:
Mathias Fredriksson
2022-11-14 13:48:44 +02:00
committed by GitHub
parent cbb1e91372
commit c515085450
2 changed files with 15 additions and 12 deletions
+3 -3
View File
@@ -174,7 +174,7 @@ func (a *agent) run(ctx context.Context) error {
if err != nil {
return xerrors.Errorf("fetch metadata: %w", err)
}
a.logger.Info(context.Background(), "fetched metadata")
a.logger.Info(ctx, "fetched metadata")
oldMetadata := a.metadata.Swap(metadata)
// The startup script should only execute on the first run!
@@ -208,7 +208,7 @@ func (a *agent) run(ctx context.Context) error {
a.closeMutex.Lock()
network := a.network
a.closeMutex.Unlock()
if a.network == nil {
if network == nil {
a.logger.Debug(ctx, "creating tailnet")
network, err = a.createTailnet(ctx, metadata.DERPMap)
if err != nil {
@@ -365,7 +365,7 @@ func (a *agent) runCoordinator(ctx context.Context, network *tailnet.Conn) error
return err
}
defer coordinator.Close()
a.logger.Info(context.Background(), "connected to coordination server")
a.logger.Info(ctx, "connected to coordination server")
sendNodes, errChan := tailnet.ServeCoordinator(coordinator, network.UpdateNodes)
network.SetNodeCallback(sendNodes)
select {