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

Fix --ignore-running not working with -p/-t in delete cmd #1578

Merged
merged 1 commit into from Jun 6, 2022

Conversation

piyush-garg
Copy link
Contributor

@piyush-garg piyush-garg commented Jun 2, 2022

This will add the fix to --ignore-running=true is not working with
-p/-t/--clustertask in delete cmd resulting in deleting all runs.

A bit of refactoring and adds unit tests

Fix #1571

Submitter Checklist

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

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

Fix --ignore-running not working with -p/-t in delete cmd

This will add the fix to --ignore-running=true is not working with
-p/-t/--clustertask in delete cmd resulting in deleting all runs.

A bit of refactoring and adds unit tests

Fix tektoncd#1571
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 2, 2022
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 2, 2022
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 2, 2022
@piyush-garg
Copy link
Contributor Author

/retest

Comment on lines +264 to +275
{
ObjectMeta: metav1.ObjectMeta{
Name: "tr0-8",
Namespace: "ns",
Labels: map[string]string{"tekton.dev/task": "random"},
},
Spec: v1alpha1.TaskRunSpec{
TaskRef: &v1alpha1.TaskRef{
Name: "random",
Kind: v1alpha1.NamespacedTaskKind,
},
},
Copy link
Member

Choose a reason for hiding this comment

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

I guess we can avoid adding tests for the v1alpha1 as they anyhow are converted to v1beta1. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now i added them, but if we want we can create an epic and remove in the whole codebase

Comment on lines +177 to +184
{
ObjectMeta: metav1.ObjectMeta{
Name: "pipeline-run-4",
Namespace: "ns",
CreationTimestamp: metav1.Time{Time: clock.Now()},
Labels: map[string]string{"tekton.dev/pipeline": "pipeline"},
},
Spec: v1alpha1.PipelineRunSpec{
Copy link
Member

Choose a reason for hiding this comment

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

same as above

Comment on lines +691 to +706
name: "Delete all of task with default --ignore-running",
command: []string{"delete", "-t", "random", "-f", "-n", "ns", "--ignore-running"},
dynamic: seeds[9].dynamicClient,
input: seeds[9].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of task with explicit --ignore-running true",
command: []string{"delete", "-t", "random", "-f", "-n", "ns", "--ignore-running=true"},
dynamic: seeds[10].dynamicClient,
input: seeds[10].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
Copy link
Member

Choose a reason for hiding this comment

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

seems to be duplicate as the default value of --ignore-running is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it to check the default behavior, if somehow the default behavior changes in future

Comment on lines +718 to +731
name: "Delete all of clustertask with default --ignore-running",
command: []string{"delete", "--clustertask", "random", "-f", "-n", "ns", "--ignore-running"},
dynamic: seeds[12].dynamicClient,
input: seeds[12].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of clustertask with explicit --ignore-running true",
command: []string{"delete", "--clustertask", "random", "-f", "-n", "ns", "--ignore-running=true"},
dynamic: seeds[13].dynamicClient,
input: seeds[13].pipelineClient,
inputStream: nil,
Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines +1514 to +1526
name: "Delete all of task with default --ignore-running",
command: []string{"delete", "-t", "random", "-f", "-n", "ns", "--ignore-running"},
dynamic: seeds[11].dynamicClient,
input: seeds[11].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with Task \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of task with explicit --ignore-running true",
command: []string{"delete", "-t", "random", "-f", "-n", "ns", "--ignore-running=true"},
dynamic: seeds[12].dynamicClient,
input: seeds[12].pipelineClient,
Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines +1541 to +1551
name: "Delete all of clustertask with default --ignore-running",
command: []string{"delete", "--clustertask", "random", "-f", "-n", "ns", "--ignore-running"},
dynamic: seeds[14].dynamicClient,
input: seeds[14].pipelineClient,
inputStream: nil,
wantError: false,
want: "All TaskRuns(Completed) associated with ClusterTask \"random\" deleted in namespace \"ns\"\n",
},
{
name: "Delete all of clustertask with explicit --ignore-running true",
command: []string{"delete", "--clustertask", "random", "-f", "-n", "ns", "--ignore-running=true"},
Copy link
Member

Choose a reason for hiding this comment

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

same

@vinamra28
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 6, 2022
Copy link
Contributor

@pradeepitm12 pradeepitm12 left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pradeepitm12, 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:
  • OWNERS [pradeepitm12,vdemeester]

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 merged commit 1ce5288 into tektoncd:main Jun 6, 2022
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. 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.

Running PRs and TRs getting deleted with --ignore-running=true
5 participants