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

Refactored Tink Worker #596

Merged
merged 1 commit into from
Apr 4, 2022
Merged

Conversation

micahhausler
Copy link
Contributor

@micahhausler micahhausler commented Mar 14, 2022

Description

  • Externalized worker package for testability
  • Created ContainerManager and ContainerLogger abstractions
  • Added tests for new interfaces
  • Cleaned up worker method arguments (logger is now passed via context)
  • Left worker logic unchanged
  • Refactored Worker struct and initialization

Why is this needed

I was working on #573 and wanted to be able to create a 'virtual worker' with faked-out Docker client calls. This refactor will make it easy immediately test API changes and later refactor the worker logic.

How Has This Been Tested?

  • Tested locally with a workflow
  • Added unit tests

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

No impact to existing users

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@codecov
Copy link

codecov bot commented Mar 14, 2022

Codecov Report

Merging #596 (8292b4b) into main (e1e2af6) will increase coverage by 2.24%.
The diff coverage is 53.52%.

❗ Current head 8292b4b differs from pull request most recent head 5eb8c9b. Consider uploading reports for the commit 5eb8c9b to get more accurate results

@@            Coverage Diff             @@
##             main     #596      +/-   ##
==========================================
+ Coverage   43.41%   45.66%   +2.24%     
==========================================
  Files          51       52       +1     
  Lines        3107     3147      +40     
==========================================
+ Hits         1349     1437      +88     
+ Misses       1673     1624      -49     
- Partials       85       86       +1     
Impacted Files Coverage Δ
cmd/tink-worker/worker/worker.go 0.00% <0.00%> (ø)
cmd/tink-worker/worker/registry.go 80.76% <80.76%> (ø)
cmd/tink-worker/worker/container_manager.go 98.57% <98.57%> (ø)
cmd/tink-worker/worker/log_capturer.go 100.00% <100.00%> (ø)

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 e1e2af6...5eb8c9b. Read the comment docs.

@micahhausler micahhausler force-pushed the refactor/tink-worker branch 14 times, most recently from 6a3a391 to 43c3fed Compare March 15, 2022 17:15
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.

Looks really good, thanks for the work. I've only got minor issue with a few things, please see the comments.

cmd/tink-worker/worker/container_logger.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/container_manager.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/container_manager_test.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/container_manager_test.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/registry.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/registry.go Outdated Show resolved Hide resolved
cmd/tink-worker/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.

looks like the only hang up is the logger := log.Test calls should be inside the t.Run to be most effective. 🤔 not even sure what would happen if child test were to fail, pretty sure the logs will still get printed but it'd also include the successful sibling tests too

cmd/tink-worker/worker/container_manager_test.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/container_manager_test.go Outdated Show resolved Hide resolved
cmd/tink-worker/worker/log_capturer_test.go Outdated Show resolved Hide resolved
@micahhausler
Copy link
Contributor Author

@mmlb Fixed logger initialization

@micahhausler micahhausler force-pushed the refactor/tink-worker branch 3 times, most recently from b685e4d to 2b38d71 Compare March 18, 2022 17:22
@micahhausler
Copy link
Contributor Author

@mmlb anything else on this?

@micahhausler micahhausler force-pushed the refactor/tink-worker branch 2 times, most recently from f5a14df to f8617f6 Compare March 24, 2022 21:48
thebsdbox
thebsdbox previously approved these changes Mar 30, 2022
Copy link
Contributor

@thebsdbox thebsdbox left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks for the additional testing !

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.

lgtm, just the one comment about the public strings that seem unnecessary.

cmd/tink-worker/worker/container_manager.go Outdated Show resolved Hide resolved
* Create ContainerManager and LogCapturer abstractions
* Add tests for new interfaces
* Clean up worker method arguments

Signed-off-by: Micah Hausler <mhausler@amazon.com>
@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label Apr 4, 2022
@mmlb mmlb removed the request for review from displague April 4, 2022 21:10
@mergify mergify bot merged commit 07cf28c into tinkerbell:main Apr 4, 2022
@displague displague added this to the 0.7.0 milestone Aug 15, 2022
mergify bot added a commit that referenced this pull request Aug 29, 2022
I'm a maintainer of several other services often related to the Kuberenetes back-end/Kubernetes controllers and I'm taking ownership for a lot of release synchronization making it both appropriate and necessary for me to maintain aspects of the Tink repository.

Requirements:

- I have reviewed the [community membership guidelines](https://github.com/tinkerbell/proposals/blob/main/proposals/0024/GOVERNANCE.md)
- I have [enabled 2FA on my GitHub account](https://github.com/settings/security)
- I have subscribed to the [tinkerbell-contributors e-mail list](https://groups.google.com/g/tinkerbell-contributors)
- I am actively contributing to 1 or more Tinkerbell subprojects

Here is a list of non-trival PRs I have been the primary reviewer on:

#596
#628
#614

I have also made a number of code contributions to this repository, here are a few of them:

#638
#631
#626
#622
#612

I have also raised various issues and am driving the releasing across Tinkerbell including in this repository.

Requesting consideration of expedited responsibilities: yes

Sponsors:

- @mmlb (Maintainer)
- @micahhausler (Maintainer)
- @jacobweinstock (Core contributor in other Tinkerbell repositories)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants