Skip to content

Commit

Permalink
Include secret in task identity (#183)
Browse files Browse the repository at this point in the history
* Include secret in task identity

Plus don't fail execution if failed to notify server

* Revert ignoring errors
  • Loading branch information
fkorotkov authored Nov 30, 2020
1 parent 3213d9b commit 5490f13
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func (worker *Worker) runTask(ctx context.Context, agentAwareTask *api.PollRespo
worker.taskCompletions <- agentAwareTask.TaskId
}()

_, err = worker.rpcClient.TaskStarted(taskCtx, &api.TaskIdentification{TaskId: agentAwareTask.TaskId},
grpc.PerRPCCredentials(worker))
taskIdentification := &api.TaskIdentification{
TaskId: agentAwareTask.TaskId,
Secret: agentAwareTask.ClientSecret,
}
_, err = worker.rpcClient.TaskStarted(taskCtx, taskIdentification, grpc.PerRPCCredentials(worker))
if err != nil {
worker.logger.Errorf("failed to notify the server about the started task %d: %v",
agentAwareTask.TaskId, err)
Expand All @@ -46,8 +49,7 @@ func (worker *Worker) runTask(ctx context.Context, agentAwareTask *api.PollRespo
worker.logger.Errorf("failed to run task %d: %v", agentAwareTask.TaskId, err)
}

_, err = worker.rpcClient.TaskStopped(taskCtx, &api.TaskIdentification{TaskId: agentAwareTask.TaskId},
grpc.PerRPCCredentials(worker))
_, err = worker.rpcClient.TaskStopped(taskCtx, taskIdentification, grpc.PerRPCCredentials(worker))
if err != nil {
worker.logger.Errorf("failed to notify the server about the stopped task %d: %v",
agentAwareTask.TaskId, err)
Expand Down

0 comments on commit 5490f13

Please sign in to comment.