Skip to content

Commit

Permalink
Pass outgoing gRPC metadata (#798)
Browse files Browse the repository at this point in the history
Between contexts.
  • Loading branch information
fkorotkov authored Oct 2, 2024
1 parent 4eece3f commit f20f699
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ func (worker *Worker) runTask(
boundedCtx, cancel := context.WithTimeout(context.Background(), perCallTimeout)
defer cancel()

if md, ok := metadata.FromOutgoingContext(ctx); ok {
boundedCtx = metadata.NewOutgoingContext(boundedCtx, md)
}

localHub.WithScope(func(scope *sentry.Scope) {
scope.SetTags(cirrusSentryTags)

Expand Down Expand Up @@ -233,6 +237,10 @@ func (worker *Worker) runTask(
boundedCtx, cancel := context.WithTimeout(context.Background(), perCallTimeout)
defer cancel()

if md, ok := metadata.FromOutgoingContext(ctx); ok {
boundedCtx = metadata.NewOutgoingContext(boundedCtx, md)
}

if err = upstream.TaskStopped(boundedCtx, api.OldTaskIdentification(taskID, clientSecret)); err != nil {
worker.logger.Errorf("failed to notify the server about the stopped task %s: %v",
taskID, err)
Expand Down

0 comments on commit f20f699

Please sign in to comment.