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

[WIP] feat(pattern): add job harvester pattern #68

Closed
wants to merge 2 commits into from
Closed

[WIP] feat(pattern): add job harvester pattern #68

wants to merge 2 commits into from

Conversation

estroz
Copy link
Member

@estroz estroz commented Jul 27, 2021

Description of the change: added the pattern/jobharvester package with Job log forwarding and garbage collection functionality.

Motivation for the change: lots of operators spawn jobs for various tasks. This simple controller exposes both the primitive Harvester type to get a Job's Pod logs then delete the Pod, or a higher level controller implementation for low-LOC, background Job harvesting.

/kind feature

Signed-off-by: Eric Stroczynski ericstroczynski@gmail.com

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 27, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 27, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from estroz after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coveralls
Copy link

coveralls commented Jul 27, 2021

Pull Request Test Coverage Report for Build 1083336552

  • 93 of 332 (28.01%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-20.3%) to 60.532%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pattern/jobharvest/clientgo.go 0 11 0.0%
pattern/jobharvest/webhook.go 4 27 14.81%
pattern/jobharvest/controller.go 8 67 11.94%
pattern/jobharvest/ctrl.go 0 69 0.0%
pattern/jobharvest/harvester.go 81 158 51.27%
Totals Coverage Status
Change from base Build 1075789896: -20.3%
Covered Lines: 523
Relevant Lines: 864

💛 - Coveralls

@estroz
Copy link
Member Author

estroz commented Jul 27, 2021

@tlwu2013 @jmccormick2001 whipped up this super simple (functionality-wise) POC after our discussion yesterday. All this does is write a Job's Pod logs streams to some writer, then delete the Job. I'd like to try out some ideas for log writer interfaces as the current LogReader API is rudimentary. Let me know if you have any!

@estroz
Copy link
Member Author

estroz commented Jul 27, 2021

There is an alternative to this implementation, which does not involve adding a new controller/helper for cleaning up jobs, that imo is a more desirable approach but involves more input from library users:

  1. Provide a helper function that appends a log collection sidecar to a Job's Pod template that can access all container logs. This container must have authorization to connect to and be able to authenticate with a log server that receives logs.
  2. Use the ttlSecondsAfterFinished field to garbage collect the Job and its child resources once logs are collected.

Implementing (1) is the difficult bit, since a custom log-forwarding image is required (for production). This setup is also very log-architecture dependent.

Signed-off-by: Eric Stroczynski <ericstroczynski@gmail.com>
@estroz
Copy link
Member Author

estroz commented Jul 30, 2021

After some thought, it seems the controller + finalizer approach is the right way to go for a general solution that enforces lossless log collection. The TTL controller approach works great if you have logging infrastructure that you can drop into a pod spec, which many operators do; the logging implementation is difficult to create a pattern around since usage varies widely depending on what log aggregation system is used.

Signed-off-by: Eric Stroczynski <ericstroczynski@gmail.com>
@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 17, 2021
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 17, 2021
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Jan 16, 2022
@openshift-ci
Copy link

openshift-ci bot commented Jan 16, 2022

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants