Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching from logrus to packethost/pkg/log in worker #271

Merged
merged 4 commits into from
Sep 16, 2020

Conversation

gauravgahlot
Copy link
Contributor

@gauravgahlot gauravgahlot commented Aug 27, 2020

Description

Replacing logrus with packethost/pkg/log.

Depends on:

Why is this needed

The PR aims to keep the logging package consistent across the Tink repository.

How Has This Been Tested?

Tested the changes by executing an end-to-end workflow.

Worker Logs

{"log":"{\"level\":\"info\",\"ts\":1598612543.5217416,\"caller\":\"tink-worker/main.go:48\",\"msg\":\"starting version: 6960d5f\",\"service\":\"github.com/tinkerbell/tink\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.526199655Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.5223653,\"caller\":\"tink-worker/main.go:85\",\"msg\":\"RETRY_INTERVAL not set, using default 3 seconds\",\"service\":\"github.com/tinkerbell/tink\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.526229686Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.5223973,\"caller\":\"tink-worker/main.go:99\",\"msg\":\"MAX_RETRY not set, using default 3 retries\",\"service\":\"github.com/tinkerbell/tink\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.526236012Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.5452757,\"caller\":\"tink-worker/worker.go:142\",\"msg\":\"starting with action\",\"service\":\"github.com/tinkerbell/tink\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"actionName\":\"hello_world\",\"taskName\":\"hello world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.545666793Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.5510116,\"caller\":\"tink-worker/worker.go:166\",\"msg\":\"sent action status\",\"service\":\"github.com/tinkerbell/tink\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"actionName\":\"hello_world\",\"taskName\":\"hello world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.551388082Z"}
{"log":"{\"status\":\"Pulling from hello-world\",\"id\":\"latest\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.644575307Z"}
{"log":"{\"status\":\"Pulling fs layer\",\"progressDetail\":{},\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.644659223Z"}
{"log":"{\"status\":\"Downloading\",\"progressDetail\":{\"current\":730,\"total\":2529},\"progress\":\"[==============\\u003e                                    ]     730B/2.529kB\",\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.66942451Z"}
{"log":"{\"status\":\"Downloading\",\"progressDetail\":{\"current\":2529,\"total\":2529},\"progress\":\"[==================================================\\u003e]  2.529kB/2.529kB\",\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.669436361Z"}
{"log":"{\"status\":\"Verifying Checksum\",\"progressDetail\":{},\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.669439988Z"}
{"log":"{\"status\":\"Download complete\",\"progressDetail\":{},\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.66944226Z"}
{"log":"{\"status\":\"Extracting\",\"progressDetail\":{\"current\":2529,\"total\":2529},\"progress\":\"[==================================================\\u003e]  2.529kB/2.529kB\",\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.66944429Z"}
{"log":"{\"status\":\"Extracting\",\"progressDetail\":{\"current\":2529,\"total\":2529},\"progress\":\"[==================================================\\u003e]  2.529kB/2.529kB\",\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.66944685Z"}
{"log":"{\"status\":\"Pull complete\",\"progressDetail\":{},\"id\":\"0e03bdcc26d7\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.731208642Z"}
{"log":"{\"status\":\"Digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.731223756Z"}
{"log":"{\"status\":\"Status: Downloaded newer image for 192.168.1.1/hello-world:latest\"}\r\r\n","stream":"stdout","time":"2020-08-28T11:02:23.731226604Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.6948822,\"caller\":\"tink-worker/action.go:203\",\"msg\":\"starting container with cmd: []\",\"service\":\"github.com/tinkerbell/tink\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"actionName\":\"hello_world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.731228638Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864270483Z"}
{"log":"Hello from Docker!\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864278931Z"}
{"log":"This message shows that your installation appears to be working correctly.\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864281213Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864283136Z"}
{"log":"To generate this message, Docker took the following steps:\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864284705Z"}
{"log":" 1. The Docker client contacted the Docker daemon.\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864286483Z"}
{"log":" 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864288907Z"}
{"log":"    (amd64)\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864290903Z"}
{"log":" 3. The Docker daemon created a new container from that image which runs the\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864292477Z"}
{"log":"    executable that produces the output you are currently reading.\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864294192Z"}
{"log":" 4. The Docker daemon streamed that output to the Docker client, which sent it\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864295866Z"}
{"log":"    to your terminal.\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864297598Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864299188Z"}
{"log":"To try something more ambitious, you can run an Ubuntu container with:\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864300687Z"}
{"log":" $ docker run -it ubuntu bash\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864302378Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864303968Z"}
{"log":"Share images, automate workflows, and more with a free Docker ID:\r\n","stream":"stdout","time":"2020-08-28T11:02:23.86430546Z"}
{"log":" https://hub.docker.com/\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864307212Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864308793Z"}
{"log":"For more examples and ideas, visit:\r\n","stream":"stdout","time":"2020-08-28T11:02:23.86431029Z"}
{"log":" https://docs.docker.com/get-started/\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864311973Z"}
{"log":"\r\n","stream":"stdout","time":"2020-08-28T11:02:23.864313659Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.9096792,\"caller\":\"tink-worker/action.go:266\",\"msg\":\"starting to remove container: eff322d7a5a7bada3d179be6ec927ac2fcac8873c677d2d91d79cfe3fee359f2\",\"service\":\"github.com/tinkerbell/tink\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"actionName\":\"hello_world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.911821295Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.9113615,\"caller\":\"tink-worker/action.go:86\",\"msg\":\"container removed with status: ACTION_SUCCESS\",\"service\":\"github.com/tinkerbell/tink\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"actionName\":\"hello_world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.911833548Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.9113853,\"caller\":\"tink-worker/action.go:133\",\"msg\":\"action container exit status code: ACTION_SUCCESS\",\"service\":\"github.com/tinkerbell/tink\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"actionName\":\"hello_world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.91183715Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.9146202,\"caller\":\"tink-worker/worker.go:211\",\"msg\":\"sent action status\",\"service\":\"github.com/tinkerbell/tink\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\",\"actionName\":\"hello_world\",\"taskName\":\"hello world\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.915028437Z"}
{"log":"{\"level\":\"info\",\"ts\":1598612543.916867,\"caller\":\"tink-worker/worker.go:217\",\"msg\":\"reached to end of workflow\",\"service\":\"github.com/tinkerbell/tink\",\"workerId\":\"0eba0bf8-3772-4b4a-ab9f-6ebe93b90a94\",\"workflowId\":\"b3a88595-5bfd-40ed-bd32-766adeab4fa2\"}\r\n","stream":"stdout","time":"2020-08-28T11:02:23.917199393Z"}

@gauravgahlot gauravgahlot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 27, 2020
@gauravgahlot gauravgahlot self-assigned this Aug 27, 2020
@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #271 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #271   +/-   ##
=======================================
  Coverage   24.24%   24.24%           
=======================================
  Files          15       15           
  Lines        1353     1353           
=======================================
  Hits          328      328           
  Misses       1006     1006           
  Partials       19       19           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 966682b...92b240d. Read the comment docs.

@gianarb
Copy link
Contributor

gianarb commented Aug 27, 2020

Thank you for taking care of it.
Do you mind to copy/paste here a sample of the new logs?
Thanks

@gauravgahlot gauravgahlot added the do-not-merge Signal to Mergify to block merging of the PR. label Aug 27, 2020
@thebsdbox
Copy link
Contributor

Looks like a fantastic start at this 👍

@gauravgahlot
Copy link
Contributor Author

@gianarb @thebsdbox
Added new logs to the description.

@gauravgahlot gauravgahlot removed the do-not-merge Signal to Mergify to block merging of the PR. label Aug 28, 2020
@mmlb
Copy link
Contributor

mmlb commented Sep 3, 2020

@gauravgahlot similar to tinkerbell/osie#107 some of those lines look like they did not come from packethost/pkg/log (the ones missing ts, caller, service keys). I suspect those are from output of docker exec/run -t since it looks like image fetching output and the \r\n is added by docker when -t is passed in I think

gianarb
gianarb previously approved these changes Sep 3, 2020
@mmlb
Copy link
Contributor

mmlb commented Sep 3, 2020

@gauravgahlot please rebase

gianarb
gianarb previously approved these changes Sep 4, 2020
mergify bot added a commit to tinkerbell/smee that referenced this pull request Sep 4, 2020
## Description

The PR updates Boots to use the latest version of `packethost/pkg/log` package.

## Why is this needed

Required for dependent [PR tink #271](tinkerbell/tink#271).

## How Has This Been Tested?

Tested by executing an end-to-end workflow.
@mmlb mmlb changed the title Switching from logrus to 'packethost/pkg/log' in worker Switching from logrus to packethost/pkg/log in worker Sep 4, 2020
mergify bot added a commit to tinkerbell/hegel that referenced this pull request Sep 4, 2020
## Description

The PR updates Hegel to use the latest version of `packethost/pkg/log` package.

## Why is this needed

Required for dependent [PR tink #271](tinkerbell/tink#271).

## How Has This Been Tested?

Tested by executing an end-to-end workflow.
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things need updating wrt the log calls. Also can you change all calls of fmt.Errorf to errors.Wrapf instead.

cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
gianarb
gianarb previously approved these changes Sep 8, 2020
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you change the calls to errors.Wrapf to just errors.Wrap where there's no fmt'ing done?

cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/main.go Outdated Show resolved Hide resolved
cmd/tink-worker/main.go Outdated Show resolved Hide resolved
cmd/tink-worker/main.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 things should be fixed throughout the whole diff:

  1. Please update the cases where errors.Wrapf was used but errors.Wrap is better.
  2. A bunch of log.With()s are called with context keys that aren't very good keys, should single word for easy lookup. Most of the keys uses actually look like they would be passed to Info() instead.

cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/action.go Outdated Show resolved Hide resolved
@gauravgahlot gauravgahlot force-pushed the worker-logs branch 2 times, most recently from c59f765 to 20b962b Compare September 11, 2020 05:48
@gauravgahlot gauravgahlot requested a review from mmlb September 11, 2020 06:09
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allllllllmost there.

cmd/tink-worker/action.go Outdated Show resolved Hide resolved
cmd/tink-worker/main.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker.go Show resolved Hide resolved
cmd/tink-worker/worker.go Show resolved Hide resolved
cmd/tink-worker/worker.go Show resolved Hide resolved
@mmlb
Copy link
Contributor

mmlb commented Sep 15, 2020

@gauravgahlot can you edit the waitContainer now returns only one 'error' type and explain why its being done please.

The second error type returned by waitContainer was ignored and never logged or used by
its only caller executeAction. So, there is no point in returning two error types.

Signed-off-by: Gaurav Gahlot <[email protected]>
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash the review fixes into the replace 'logrus' with 'packethost/pkg/log' commit.

Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally! Thanks for all the follow through.

@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label Sep 16, 2020
@mergify mergify bot merged commit 16f8767 into tinkerbell:master Sep 16, 2020
@gauravgahlot gauravgahlot deleted the worker-logs branch September 16, 2020 17:11
@displague displague mentioned this pull request Sep 21, 2020
3 tasks
@mmlb mmlb removed the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants