Skip to content

Commit ba9ddb9

Browse files
authored
Remove old taskrun finalizer (#1394)
Commit 40b47b9 introduced new compliant finalizer name. One edge case missed was that during upgrade, existing taskruns with the old finalizer name will remain on the cluster until the old finalizer name is removed. This is a temporary fix, until we can consider all deployments has switched to the new version/finalizer name.
1 parent 40b47b9 commit ba9ddb9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/reconciler/taskrun/taskrun.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tr *v1.TaskRun) pkgrecon
4545
return r.FinalizeKind(ctx, tr)
4646
}
4747

48+
// 01-Jul-2025; this is a temp solution util we consider the old finalizer name no longer used.
49+
// removeOldFinalizerIfExists removes the old finalizer from the TaskRun if it exists.
50+
func removeOldFinalizerIfExists(tr *v1.TaskRun) {
51+
const oldFinalizerName = "chains.tekton.dev"
52+
for i, f := range tr.ObjectMeta.Finalizers {
53+
if f == oldFinalizerName {
54+
tr.ObjectMeta.Finalizers = append(tr.ObjectMeta.Finalizers[:i], tr.ObjectMeta.Finalizers[i+1:]...)
55+
break
56+
}
57+
}
58+
}
59+
4860
// FinalizeKind implements taskrunreconciler.Finalizer
4961
// We utilize finalizers to ensure that we get a crack at signing every taskrun
5062
// that we see flowing through the system. If we don't add a finalizer, it could
@@ -61,11 +73,13 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, tr *v1.TaskRun) pkgreconc
6173
// Check to see if it has already been signed.
6274
if signing.Reconciled(ctx, r.Pipelineclientset, obj) {
6375
logging.FromContext(ctx).Infof("taskrun %s/%s has been reconciled", tr.Namespace, tr.Name)
76+
removeOldFinalizerIfExists(tr)
6477
return nil
6578
}
6679

6780
if err := r.TaskRunSigner.Sign(ctx, obj); err != nil {
6881
return err
6982
}
83+
removeOldFinalizerIfExists(tr)
7084
return nil
7185
}

0 commit comments

Comments
 (0)