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

feat/Cancel taskrun using entrypoint binary #6511

Merged

Conversation

chengjoey
Copy link
Member

@chengjoey chengjoey commented Apr 8, 2023

The cancellation of taskruns is now done through the entrypoint binary through a new flag called 'stop_on_cancel'. This removes the need for deleting the pods to cancel a taskrun, allowing examination of the logs on the pods from cancelled taskruns. Part of work on issue #3238
there are some codes carry over from #4618

Changes

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

if "keep-pod-on-cancel" is set to
"true" in the `feature-flags`, Taskrun can now be cancelled using the entrypoint, which results of Pods from these TaskRun to be no longer deleted: they are stopped instead.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 8, 2023
@chengjoey
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 Apr 8, 2023
@chengjoey
Copy link
Member Author

/hold
until add more tests

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 8, 2023
@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/main.go 12.5% 11.0% -1.5
cmd/entrypoint/runner.go 85.2% 85.7% 0.5
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.0% -1.8
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.0% -1.5
cmd/entrypoint/runner.go 85.2% 85.7% 0.5
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.0% -1.8
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from e53bdc8 to bc96a34 Compare April 10, 2023 06:42
@chengjoey
Copy link
Member Author

example taskrun.yaml:

apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: cancel
spec:
  taskSpec:
    steps:
    - name: step-1
      image: alpine
      script: echo "step-1 executing" && sleep 1200

after kubectl edit taskrun and add status TaskRunCancelled

check pod log:
image

describe pod:
image

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 85.7% 0.5
cmd/entrypoint/waiter.go 80.0% 57.6% -22.4
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 85.7% 0.5
cmd/entrypoint/waiter.go 80.0% 57.6% -22.4
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from bc96a34 to 0b8a9cb Compare April 10, 2023 07:20
@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 82.8% -2.4
cmd/entrypoint/waiter.go 80.0% 57.6% -22.4
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 82.8% -2.4
cmd/entrypoint/waiter.go 80.0% 57.6% -22.4
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from 0b8a9cb to cc99b2e Compare April 10, 2023 07:53
@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 82.8% -2.4
cmd/entrypoint/waiter.go 80.0% 81.8% 1.8
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 82.8% -2.4
cmd/entrypoint/waiter.go 80.0% 81.8% 1.8
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 85.7% -4.1
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from cc99b2e to 0f2e740 Compare April 10, 2023 10:03
@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 86.2% 1.0
cmd/entrypoint/waiter.go 80.0% 81.8% 1.8
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 89.8% 0.0
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 86.2% 1.0
cmd/entrypoint/waiter.go 80.0% 81.8% 1.8
pkg/apis/config/feature_flags.go 92.7% 91.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.4% -1.5
pkg/pod/entrypoint.go 89.8% 89.8% 0.0
pkg/pod/pod.go 91.8% 92.0% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 84.6% -0.3

@chengjoey
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 10, 2023
@chengjoey
Copy link
Member Author

#4618 (comment)

added a new func WaitWithContext for Waiter

@chengjoey
Copy link
Member Author

#4618 (comment)

I changed the logic of this part to entrypointer to judge whether the ContextCanceld error was triggered to determine whether the task was canceled

@chengjoey
Copy link
Member Author

#4618 (comment)

cancel or fail the taskrun has been merged into one function

@chengjoey
Copy link
Member Author

#4618 (comment)

For PipelineRun or TaskRun reconciler, the cancellation logic is just changed from delete pod to patch pod

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 86.2% 1.0
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 90.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.2% -1.6
pkg/pod/entrypoint.go 89.8% 89.4% -0.4
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from 708ae81 to cc78142 Compare August 29, 2023 15:07
@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 86.2% 1.0
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 90.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.2% -1.6
pkg/pod/entrypoint.go 89.8% 89.4% -0.4
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 86.2% 1.0
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 90.8% -0.9
pkg/entrypoint/entrypointer.go 87.8% 86.2% -1.6
pkg/pod/entrypoint.go 89.8% 89.4% -0.4
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@jerop jerop added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 20, 2023
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

@chengjoey thank you for these contributions, and for the patience with the reviews

this pull request generally looks good to me, one ask is that you improve the code coverage to at least maintain the current coverage e.g. add a test case for setting the feature flag to something invalid

@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from cc78142 to 7449f0f Compare September 21, 2023 16:02
@chengjoey
Copy link
Member Author

@chengjoey thank you for these contributions, and for the patience with the reviews

this pull request generally looks good to me, one ask is that you improve the code coverage to at least maintain the current coverage e.g. add a test case for setting the feature flag to something invalid

Thanks~ i have added some test cases for entrypoint feature-flags entrypointer
PLAT @jerop @lbernick

@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 83.3% 84.5% 1.1
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 93.9% 2.2
pkg/entrypoint/entrypointer.go 87.8% 87.4% -0.5
pkg/pod/entrypoint.go 89.8% 93.6% 3.8
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 83.3% 86.2% 2.9
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 93.9% 2.2
pkg/entrypoint/entrypointer.go 87.8% 87.4% -0.5
pkg/pod/entrypoint.go 89.8% 93.6% 3.8
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2023
@chitrangpatel
Copy link
Contributor

@chengjoey Thanks for your work on this. The changes look good to me. Please rebase this PR. I'm happy to LGTM it after.

through a new flag called 'stop_on_cancel'. This removes the need for
deleting the pods to cancel a taskrun, allowing examination of the logs
on the pods from cancelled taskruns. Part of work on issue tektoncd#3238

Signed-off-by: chengjoey <[email protected]>
@chengjoey chengjoey force-pushed the feat/cancel-taskrun-useing-entrypoint branch from 7449f0f to a3d6e7f Compare October 17, 2023 03:52
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 17, 2023
@chengjoey
Copy link
Member Author

@chengjoey Thanks for your work on this. The changes look good to me. Please rebase this PR. I'm happy to LGTM it after.

Thanks @chitrangpatel , pr has been rebased

@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/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 84.5% -0.7
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 93.9% 2.2
pkg/entrypoint/entrypointer.go 87.8% 87.4% -0.5
pkg/pod/entrypoint.go 89.4% 93.4% 4.0
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
cmd/entrypoint/main.go 12.5% 11.6% -0.9
cmd/entrypoint/runner.go 85.2% 84.5% -0.7
cmd/entrypoint/waiter.go 80.0% 81.0% 1.0
pkg/apis/config/feature_flags.go 91.7% 93.9% 2.2
pkg/entrypoint/entrypointer.go 87.8% 87.4% -0.5
pkg/pod/entrypoint.go 89.4% 93.4% 4.0
pkg/pod/pod.go 92.5% 92.7% 0.2
pkg/reconciler/taskrun/taskrun.go 85.4% 85.1% -0.3

@chengjoey
Copy link
Member Author

/test pull-tekton-pipeline-unit-tests

@chitrangpatel
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2023
@tekton-robot tekton-robot merged commit 4cae9cb into tektoncd:main Oct 17, 2023
2 checks passed
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants