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 flag to task and pipeline to only delete related resources #608

Merged
merged 1 commit into from Jan 28, 2020
Merged

Add flag to task and pipeline to only delete related resources #608

merged 1 commit into from Jan 28, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jan 15, 2020

Changes

Fixes #589

This commit adds a flag to delete resources related to a parent - a
taskrun's parent is a task, a pipelinerun's parent is a pipeline -
without deleting the task or pipeline.

The flags are:
tkn taskrun delete --task task-name
tkn pipelinerun delete --pipeline pipeline-name

TODO:

  • Add unit tests for the rewritten flags --task and --pipeline

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)
  • Includes docs (if user facing)
  • Regenerate the manpages and docs with make docs and make man if needed.
  • Run the code checkers with make check
  • Commit messages follow commit message best practices

Release Notes

tkn delete pipeline --delete-pipelineruns flag has been added to allow deletion of only the pipelineruns related to a pipeline (not the pipeline itself)
tkn delete task --delete-taskruns flag has been added to allow deletion of only the taskruns related to a task (not the task itself)

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 15, 2020
@ghost
Copy link
Author

ghost commented Jan 15, 2020

I wonder if the flags should be --only-pipelineruns and --only-taskruns instead of --delete-pipelineruns and --delete-taskruns. Anyone got an opinion on that?

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.4% 95.0% 0.6
pkg/cmd/condition/delete.go 95.0% 95.5% 0.5
pkg/cmd/eventlistener/delete.go 95.0% 95.5% 0.5
pkg/cmd/pipeline/delete.go 93.9% 94.9% 0.9
pkg/cmd/pipelinerun/delete.go 95.0% 95.5% 0.5
pkg/cmd/task/delete.go 93.9% 94.9% 0.9
pkg/cmd/taskrun/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggerbinding/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggertemplate/delete.go 95.0% 95.5% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 87.5% -5.8

@chmouel
Copy link
Member

chmouel commented Jan 15, 2020

tkn pipeline delete --only-runs ? but that may be too cryptic,

I rather have the --only-* prefix which makes more sense imho

@danielhelfand
Copy link
Member

tkn pipeline delete --only-runs ? but that may be too cryptic,

I rather have the --only-* prefix which makes more sense imho

--only is more clear to me that you aren't deleting anything else. I do prefer --only-pipelineruns/--only-taskruns to be more explicit.

@ghost
Copy link
Author

ghost commented Jan 15, 2020

ok great, I've gone with --only-taskruns and --only-pipelineruns, thanks folks

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.4% 95.0% 0.6
pkg/cmd/condition/delete.go 95.0% 95.5% 0.5
pkg/cmd/eventlistener/delete.go 95.0% 95.5% 0.5
pkg/cmd/pipeline/delete.go 93.9% 94.9% 0.9
pkg/cmd/pipelinerun/delete.go 95.0% 95.5% 0.5
pkg/cmd/task/delete.go 93.9% 94.9% 0.9
pkg/cmd/taskrun/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggerbinding/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggertemplate/delete.go 95.0% 95.5% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 87.5% -5.8

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/clustertask/delete.go 94.4% 95.0% 0.6
pkg/cmd/condition/delete.go 95.0% 95.5% 0.5
pkg/cmd/eventlistener/delete.go 95.0% 95.5% 0.5
pkg/cmd/pipeline/delete.go 93.9% 94.9% 0.9
pkg/cmd/pipelineresource/delete.go 95.0% 95.5% 0.5
pkg/cmd/pipelinerun/delete.go 95.0% 95.5% 0.5
pkg/cmd/task/delete.go 93.9% 94.9% 0.9
pkg/cmd/taskrun/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggerbinding/delete.go 95.0% 95.5% 0.5
pkg/cmd/triggertemplate/delete.go 95.0% 95.5% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 93.8% 0.4

@vdemeester
Copy link
Member

So… I think we need to think about this a little bit more 🤔 We have something a little bit like that when listing TaskRun and PipelineRun.

# List all taskruns of task 'foo' in namespace 'bar'
tkn taskrun list foo -n bar

This is in taskrun subcommand. You can filter the TaskRun of a given Task.

  • To be consistent, I would think we could have this on delete too, as tkn taskrun delete --task=foo or something ?
  • To be even more consitent, tkn taskrun list foo should be deprecated (but still supported for a while), and use a flag instead (the same as for delete, so tkn taskrun list --task=foo) ?

This would also allow to delete all TaskRun for multiple Tasks, with tkn taskrun delete --task=foo --task=bar.

@chmouel @piyush-garg @danielhelfand @sbwsg wdyt ?

@chmouel
Copy link
Member

chmouel commented Jan 16, 2020

To be consistent, I would think we could have this on delete too, as tkn taskrun delete --task=foo or something ?

IMHO I think that's less than intuitive... I like how @sbwsg implemented it, where I can tell to myself :

"I want to delete all the auto created taskruns attached to my task named foo"

and map it into a command that looks as what i am thinking :

tkn delete task foo --delete-taskruns

your suggested command :

tkn taskrun delete --task=foo

looks not intuitive to me.. (and we loose completion)

To be even more consitent, tkn taskrun list foo should be deprecated (but still supported for a while), and use a flag instead (the same as for delete, so tkn taskrun list --task=foo) ?

👎 on this, even tho this may look more logical, this is not going to be intuitive for our end users

@vdemeester
Copy link
Member

🤔 so tkn taskrun list foo and tkn task delete --delete-taskruns are intuitive but tkn taskrun delete --task=foo is not ?

It might be just me, but as a user, if I want to delete all TaskRuns from a Task I would naively go to tkn taskrun subcommands than tkn task subcommands (aka I would look for a filtering option on the TaskRun delete command). This is what would feel intuitive for me 😛

@chmouel
Copy link
Member

chmouel commented Jan 16, 2020

Because you are deep neck into the project and you know what a run is 🤣

We don't necessary expose the *Runs with CLI, we just say here is a task/pipeline and start it(tkn task start)....

we give a taskrun objects so we can do stuff on it... but it really start from the task for the user...

@vdemeester
Copy link
Member

Because you are deep neck into the project and you know what a run is rofl

We don't necessary expose the *Runs with CLI, we just say here is a task/pipeline and start it(tkn task start)....

we give a taskrun objects so we can do stuff on it... but it really start from the task for the user...

right, that might make sense 👼 but then should the flag be just about runs or even a subtask 😈 ? (tkn task delete runs)

@chmouel
Copy link
Member

chmouel commented Jan 16, 2020

? (tkn task delete runs)

I am okay with that! but i'll let others weight in!

@ghost
Copy link
Author

ghost commented Jan 16, 2020

I gotta be honest I don't feel strongly either way - do we want both?

tkn taskrun delete --task my-task
tkn task delete runs my-task

My eye likes the syntax of the first one better. But I agree that users are task-centric, not so much taskrun-centric.

@danielhelfand do you have any thoughts here from when you initially created the issue?

@ghost
Copy link
Author

ghost commented Jan 16, 2020

Maybe we get even more fancy:

tkn taskrun delete --filter "task=my-task"?

@chmouel
Copy link
Member

chmouel commented Jan 16, 2020

Good idea @sbwsg !

I am +1 on the filter thing... and we can add it to tkn * list too... (ie: #617)

I think people are already used to the label selection from kubectl so this may transpose well..

@vdemeester
Copy link
Member

As @chmouel, I like the fancy solution 😛

@siamaksade
Copy link

Filtering with explicit task and pipelinerun flags IMO is more intuitive. The key=value syntax incorrectly implies that it's similar to k8s labels:
tkn taskrun delete --task tname
tkn taskrun delete --pipelinerun prname

Same would go for the list:
tkn taskrun list --task tname
tkn taskrun list --pipelinerun prname

Could make sense to support the same syntax for the pipelinerun too in addition to the existing syntax:
tkn pipelinerun list pname
tkn pipelinerun list --pipeline pname

I'm opposed to indirect delete commands like:
tkn delete task tname --delete-taskruns

The command reads delete tasks except that it doesn't do that, it deletes taskruns.

@ghost
Copy link
Author

ghost commented Jan 17, 2020

Great feedback, thanks @siamaksade, you make some excellent points. I think my next step here is to bring this up at the next CLI WG.

@ghost
Copy link
Author

ghost commented Jan 21, 2020

OK cool, after quick chat in the working group, we're going to go with tkn taskrun delete --task tname style syntax

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/pipeline/delete.go 93.9% 94.4% 0.5
pkg/cmd/task/delete.go 93.9% 94.4% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 93.8% 0.4

@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/pipeline/delete.go 93.9% 94.4% 0.5
pkg/cmd/task/delete.go 93.9% 94.4% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 88.9% -4.4

@danielhelfand
Copy link
Member

Failures are -- FATAL: The documentation or manpages didn't seem to be generated :

Just need to update docs/manpages.

TaskRun and PipelineRun delete commands provide a mechanism to delete both the
taskruns or pipelineruns related to a task or pipeline.

This commit adds a flag to delete resources related to a parent - a
taskrun's parent is a task, a pipelinerun's parent is a pipeline -
without deleting the task or pipeline.

The flags are:
`tkn taskrun delete --task task-name`
`tkn pipelinerun delete --pipeline pipeline-name`
@tekton-robot
Copy link
Contributor

The following is the coverage report on pkg/.
Say /test pull-tekton-cli-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/cmd/pipeline/delete.go 93.9% 94.4% 0.5
pkg/cmd/task/delete.go 93.9% 94.4% 0.5
pkg/helper/deleter/deleter.go 50.0% 100.0% 50.0
pkg/helper/options/delete.go 93.3% 88.9% -4.4

@vdemeester
Copy link
Member

It is green 🎉
/meow

@tekton-robot
Copy link
Contributor

@vdemeester: cat image

In response to this:

It is green 🎉
/meow

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.

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.

LGTM 🎉

@tekton-robot
Copy link
Contributor

[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 Jan 28, 2020
@chmouel
Copy link
Member

chmouel commented Jan 28, 2020

/lgtm

🔥

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2020
@tekton-robot tekton-robot merged commit 204b8f7 into tektoncd:master Jan 28, 2020
@ghost
Copy link
Author

ghost commented Jan 28, 2020

🙏 woo, cheers!

@chmouel chmouel mentioned this pull request Feb 5, 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 lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Only Delete PipelineRuns or TaskRuns of a Pipeline or Task
6 participants