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

Add Signal Forwarding to Entrypoint Runner #2426

Merged
merged 1 commit into from
May 13, 2020

Conversation

waveywaves
Copy link
Member

@waveywaves waveywaves commented Apr 16, 2020

The Entrypoint process should be notified and signals
received should be propogated as necessary. This signal
forwarding mimics the one in
https://github.com/pablo-ruth/go-init which is an golang
implementation of https://github.com/Yelp/dumb-init .

The cmd.Run() has also been replaced with a cmd.Start()
and cmd.Wait() to systematically start the command
and Wait for it's completion without prematurely exiting.

Changes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

The Entrypoint process is now notified for signals and the same are propogated using a dedicated PID Group of the Entrypoint process.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Apr 16, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 16, 2020
@waveywaves
Copy link
Member Author

waveywaves commented Apr 16, 2020

@imjasonh
Copy link
Member

Nice! Can you add to the release notes section of the PR since I think this is something we'll want to call out in the next release.

Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

Is there any kind of test case we can add with this change to demonstrate that it works, and prevent regressions in future changes?

cmd/entrypoint/runner.go Outdated Show resolved Hide resolved
@waveywaves waveywaves force-pushed the update/entrypoint branch 2 times, most recently from 83842eb to 3f58719 Compare April 17, 2020 00:27
@waveywaves
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@waveywaves
Copy link
Member Author

tkn tr delete is noticably faster I feel when running taskruns on this branch 🤔

@waveywaves waveywaves force-pushed the update/entrypoint branch from bd8299e to 49abf13 Compare May 4, 2020 04:56
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 4, 2020

CLA Check
The committers are authorized under a signed CLA.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 0.0% 81.0% 81.0

@vdemeester
Copy link
Member

/test pull-tekton-pipeline-integration-tests

2 similar comments
@waveywaves
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@waveywaves
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

@tekton-robot tekton-robot requested review from afrittoli and a user May 5, 2020 10:12
@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

/meow
/cc @afrittoli @bobcatfish @sbwsg

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.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

The pull request process is described 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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2020
for s := range rr.signals {
// Forward signal to main process and all children
if s != syscall.SIGCHLD {
_ = syscall.Kill(-cmd.Process.Pid, s.(syscall.Signal))
Copy link

Choose a reason for hiding this comment

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

Curious - why do we negate cmd.Process.Pid here?

Copy link
Member Author

@waveywaves waveywaves May 6, 2020

Choose a reason for hiding this comment

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

If PID given is negative, then the signal is sent to the process (with the same PID) as well as all it's children. This ensures signal forwarding.

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

@vdemeester @imjasonh this seems pretty much ready to go, any objections on your end?

cmd/entrypoint/runner_test.go Show resolved Hide resolved
@imjasonh
Copy link
Member

Thanks for pinging @bobcatfish, the PR lgtm but I'll hold off in case others have questions.

The Entrypoint process should be notified and signals
received should be propogated as necessary. This signal
forwarding mimics the one in
https://github.com/pablo-ruth/go-init which is an golang
implementation of https://github.com/Yelp/dumb-init .

The cmd.Run() has also been replaced with a cmd.Start()
and cmd.Wait() to systematically start the command
and Wait for it's completion without prematurely exiting.
@waveywaves waveywaves force-pushed the update/entrypoint branch from 49abf13 to 4ecb74c Compare May 13, 2020 09:23
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/entrypoint/runner.go 0.0% 81.0% 81.0

@vdemeester
Copy link
Member

/retest

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks @waveywaves !!

// TestRealRunnerSignalForwarding will artificially put an interrupt signal (SIGINT) in the rr.signals chan.
// The chan will not be reinitialized in the runner considering we have already initialized it here.
// Once the sleep process starts, if the signal is successfully received by the parent process, it
// will interrupt and stop the sleep command.
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for adding the docstring!

Copy link
Member Author

Choose a reason for hiding this comment

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

:3

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 13, 2020
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

@waveywaves
Copy link
Member Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label May 13, 2020
@tekton-robot tekton-robot merged commit 0487692 into tektoncd:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants