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

Automatically delete old pr and tr on dogfooding #442

Merged
merged 1 commit into from
Jun 25, 2020

Conversation

afrittoli
Copy link
Member

Changes

Add a new trigger to the tekoncd event listener, for cleanup.
The triggers runs tkn pr|tr delete --all with a --keep param,
to keep the latest N runs.

Add a cluster role and a service account bound to it in the
default and tektonci namespaces. The cluster role gives
permission to list and delete prs and trs.

Add a cluster resource that uses the new service account.
This is used by the cleanup task to direct tkn to the
dogfooding cluster.

Add a new cronjob base for cleanup jobs, and a two jobs
based out of it, to cleanup in the default and tektonci
namespaces on the dogfooding cluster,

Once this is in place, it will be easy to add more cronjobs
to cleanup other namespaces / clusters if needed.
It will also be possiblo iterate on the cleanup task adding
more features and nobs to it.

The secret used by the pipeline resources must be created
manually once this is provisioned for it to work.

Fixes #439

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.

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 24, 2020
@tekton-robot tekton-robot requested review from abayer and a user June 24, 2020 11:25
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2020
@tekton-robot
Copy link
Contributor

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.

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.

/meow

@tekton-robot
Copy link
Contributor

@vdemeester: cat image

In response to this:

/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.

@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 Jun 24, 2020
@afrittoli afrittoli force-pushed the issues/439-cleanup branch 4 times, most recently from 5330f35 to 4057535 Compare June 24, 2020 12:53
Add a new trigger to the tekoncd event listener, for cleanup.
The triggers runs tkn pr|tr delete --all with a --keep param,
to keep the latest N runs.

Add a cluster role and a service account bound to it in the
default and tektonci namespaces. The cluster role gives
permission to list and delete prs and trs.

Add a cluster resource that uses the new service account.
This is used by the cleanup task to direct tkn to the
dogfooding cluster.

Add a new cronjob base for cleanup jobs, and a two jobs
based out of it, to cleanup in the default and tektonci
namespaces on the dogfooding cluster,

Once this is in place, it will be easy to add more cronjobs
to cleanup other namespaces / clusters if needed.
It will also be possiblo iterate on the cleanup task adding
more features and nobs to it.

The secret used by the pipeline resources must be created
manually once this is provisioned for it to work.

Fixes tektoncd#439
Comment on lines +60 to +62
tkn pr delete -n $(params.namespace) --all --keep $(params.keep)
# Keep double the amount of tr, for standalone trs
tkn tr delete -n $(params.namespace) --all --keep $(( $(params.keep) * 2 ))
Copy link
Member

@danielhelfand danielhelfand Jun 24, 2020

Choose a reason for hiding this comment

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

Depending on the version of tkn, you should be able to use --keep without --all:

tkn pr delete -n $(params.namespace) --keep $(params.keep)

tkn tr delete -n $(params.namespace) --keep $(params.keep)

Was introduced in v0.9.0 and should provide same behavior: tektoncd/cli#921

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

@vdemeester
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2020
@tekton-robot tekton-robot merged commit 8832328 into tektoncd:master Jun 25, 2020
@vmendis-stash
Copy link

Hi,
Has this been implemented yet?
I could not find any documentation on how to activate this.
Currently I am test driving TektonCD and have a bash script to clear up the mess but really would like an automated solution.
Thank you.

@ghost
Copy link

ghost commented Jul 17, 2020

@vmendis-stash this PR is related to Tekton's own CI/CD infrastructure. We are "dogfooding" this approach to try it out. For ongoing work around a user-facing solution to this problem please follow tektoncd/experimental#479

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. 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.

Delete old TaskRuns/PipelineRuns in dogfoding?
5 participants