-
Notifications
You must be signed in to change notification settings - Fork 232
adds auto-prune per namespace #410
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
Conversation
|
The following is the coverage report on the affected files.
|
4bbafef to
1e75476
Compare
|
The following is the coverage report on the affected files.
|
pkg/reconciler/common/prune.go
Outdated
| var containers []corev1.Container | ||
|
|
||
| cmdArgs := pruneCommand(nsConfig, ns) | ||
| jobName := SimpleNameGenerator.RestrictLengthWithRandomSuffix("pruner-tkn-" + ns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let us avoid the namespace suffix. it is redundant data and it doesn't help us with any functional benefits.
Im assuming that this was done to check a cronjob was created by this pruner logic. For that, let us add a label on the CornJob (example tektonconfig.operator.tekton.dev/pruner: true)
This will be more readable. It will also help us filter our query for cronJobs from allnamespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, we will create only 1 pruner CronJob in any given namespace.
pkg/reconciler/common/prune.go
Outdated
| ownerAPIVer = "operator.tekton.dev/v1alpha1" | ||
| ownerKind = "TektonConfig" | ||
| tektonSA = "tekton-pipelines-controller" | ||
| CronName = "resource-pruner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let us make this tektoncd-resorce-pruner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done. I am only thinking of updates, is there any chance the cronjob name change will create any problem with the updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we put annotation on the cronjob we create ? If yes, then we could/should probably not rely on the name, and thus changing it now wouldn't be a problem.
That said, where is this name use : inside openshift-pipelines (then it's fine to not have tektoncd prefix I would guess), or in any annotated namespace (then, yes, we should prefix it because we are not pruning all resources, just tektoncd ones).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
earlier label/annotation was not there.
We will be adding a label this time. #410 (comment)
pkg/reconciler/common/prune.go
Outdated
| }, | ||
| ObjectMeta: v1.ObjectMeta{ | ||
| Name: CronName, | ||
| Name: CronName + "-" + targetNs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vdemeester
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is
keep: 2a default we will/would ship ? because if yes, it might be a tidy bit too small. keepvskeepSince: I tend to agree that initially both "should" not be used together, but it could make sense though : I want to keep 100 pipelineruns and those since 4 weeks, and clean those who do not fit – If I have less than 100 in 4 weeks, I clean those after 4 weeks, if I have more than 100 in 4 weeks, I clean the 100 ; or the opposite, we would have to decide there.
pkg/reconciler/common/prune.go
Outdated
| ownerAPIVer = "operator.tekton.dev/v1alpha1" | ||
| ownerKind = "TektonConfig" | ||
| tektonSA = "tekton-pipelines-controller" | ||
| CronName = "resource-pruner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we put annotation on the cronjob we create ? If yes, then we could/should probably not rely on the name, and thus changing it now wouldn't be a problem.
That said, where is this name use : inside openshift-pipelines (then it's fine to not have tektoncd prefix I would guess), or in any annotated namespace (then, yes, we should prefix it because we are not pruning all resources, just tektoncd ones).
vdemeester
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove the operator.tekton.dev/prune.resources.pipelineNames and operator.tekton.dev/prune.resources.taskNames from this feature / PR for now.
- The feature is not present in the cluster-wide CR
- It doesn't scale well, and we could probably give the user a better experience. On top of my head, we go with an annotation or a label, that if present on a TaskRun/PipelineRun, we would skip it — something like
operator.tekton.dev/prune.ignoreor something similar, and because we propagate annotation from pipeline to pipelinerun or task to taskrun, a Task or Pipeline could have this annotation too, to make all execution of it not be pruned.
|
/hold |
1e75476 to
c465ff1
Compare
|
The following is the coverage report on the affected files.
|
|
|
||
| if err := common.Prune(r.kubeClientSet, ctx, tc); err != nil { | ||
| if err := common.Prune(ctx, r.kubeClientSet, tc); err != nil { | ||
| logger.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to report this error in TektonConfig Status.
eg:
| tc.Status.MarkComponentNotReady(fmt.Sprintf("TektonTrigger: %s", err.Error())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as it is not a resource like Triggers or Pipeline of operator, should we put tekton-resource-pruner
tc.Status.MarkComponentNotReady(fmt.Sprintf("tekton-resource-pruner: %s", err.Error()))
|
The following is the coverage report on the affected files.
|
|
/lgtm |
This adds auto-pruning of taskrun and pipeline run per namespace configured specifically. adding unique schedule create a new cronjob in the annotated namespace. The default behaviour will persist, on top of it now user can annotate a namespace with unique pruning configuration. If user configures a unique schedule value by annotating a ns a new cron job in that namespace will be created. Auto purning is now enabled by default for default configurations from tektonconfig. Annotations introduced with this pr - "operator.tekton.dev/prune.skip" - "operator.tekton.dev/prune.resources" - "operator.tekton.dev/prune.strategy" - "operator.tekton.dev/prune.keep" - "operator.tekton.dev/prune.keep-since" - "operator.tekton.dev/prune.schedule" Signed-off-by: Pradeep Kumar <pradkuma@redhat.com>
|
/hold cancel |
1 similar comment
|
/hold cancel |
cb5a726 to
54b431b
Compare
rebase Done |
|
The following is the coverage report on the affected files.
|
|
@nikhil-thomas @vdemeester |
|
/lgtm |
Starting in Tekton Operator v0.58.0, TektonConfig objects must set a value for `keep` or `keepSince` if the pruner is enabled [1]. If Shipwright bootstraps the TektonConfig object and does not set a value for `.spec.pruner.keep` (or `.keepSince`), it risks failing to reconcile the TektonConfig instance or worse [2]. Fixing by setting the `keep` value to match the Tekton operator default. Fixes shipwright-io#231 [1] tektoncd/operator#410 [2] tektoncd/operator#2450
Starting in Tekton Operator v0.58.0, TektonConfig objects must set a value for `keep` or `keepSince` if the pruner is enabled [1]. If Shipwright bootstraps the TektonConfig object and does not set a value for `.spec.pruner.keep` (or `.keepSince`), it risks failing to reconcile the TektonConfig instance or worse [2]. Fixing by setting the `keep` value to match the Tekton operator default. Fixes shipwright-io#231 [1] tektoncd/operator#410 [2] tektoncd/operator#2450 Signed-off-by: Adam Kaplan <adam.kaplan@redhat.com>
This adds auto-pruning of taskrun and pipeline run per namespace
configured specifically.
adding unique schedule create a new cronjob in the annotated
namespace.
The default behaviour will persist, on top of it now user can
annotate a namespace with unique pruning configuration.
If user configures a unique schedule value by annotating a ns
a new cron job in that namespace will be created.
Auto purning is now enabled by default for default configurations
from tektonconfig.
Annotations introduced with this pr
- "operator.tekton.dev/prune.skip"
- "operator.tekton.dev/prune.resources"
- "operator.tekton.dev/prune.strategy"
- "operator.tekton.dev/prune.keep"
- "operator.tekton.dev/prune.keep-since"
- "operator.tekton.dev/prune.schedule"
Signed-off-by: Pradeep Kumar pradkuma@redhat.com
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.
Release Notes
1) Introduce resource deletion as per the age.
keep-since newly introduced to tektonconfig, this is used to delete resources on the basis of their age.
Note: keep and keep-since are mutually exclusive. ie only one should be configured.
2) Introduce pruning config for each namespace.
With this pr user would be able to configure pruning uniquely for each namespace.
This can be achieved by annotation on the namespace.
The annotations introduced are as follows