Skip to content

Commit

Permalink
Move logging into worker processing loop: (#882)
Browse files Browse the repository at this point in the history
## Description


This sets a new logger with values for each loop. Previously the loop was being set outside of the loop and all `.With` functions persisted across loops. This made the logs almost unreadable when multiple workflows were run by a single worker.

## Why is this needed



Fixes: #

## How Has This Been Tested?





## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
mergify[bot] authored Feb 19, 2024
2 parents 6da1433 + 038c6af commit cbb02e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/tink-worker/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func NewRootCommand(version string) *cobra.Command {
worker.WithLogCapture(captureActionLogs),
worker.WithPrivileged(true))

logger.Info("starting to process workflow actions", "workerID", workerID)
err = w.ProcessWorkflowActions(cmd.Context())
if err != nil {
return errors.Wrap(err, "worker Finished with error")
Expand Down
4 changes: 1 addition & 3 deletions cmd/tink-worker/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,8 @@ func (w *Worker) executeReaction(ctx context.Context, reaction string, cmd []str

// ProcessWorkflowActions gets all Workflow contexts and processes their actions.
func (w *Worker) ProcessWorkflowActions(ctx context.Context) error {
l := w.logger.WithValues("workerID", w.workerID)
l.Info("starting to process workflow actions")

for {
l := w.logger.WithValues("workerID", w.workerID)
select {
case <-ctx.Done():
return nil
Expand Down

0 comments on commit cbb02e3

Please sign in to comment.