Skip to content

Commit

Permalink
Storing PipelineRun and TaskRun deletion metadata
Browse files Browse the repository at this point in the history
Earlier, data coming during deletion like timestamp weren't stored.
This PR fixes that.
  • Loading branch information
khrm authored and tekton-robot committed Oct 23, 2024
1 parent 81dac2f commit a2b1e2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/watcher/reconciler/pipelinerun/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func isMarkedAsReadyForDeletion(taskRun *pipelinev1.TaskRun) bool {
// that we see flowing through the system. If we don't add a finalizer, it could
// get cleaned up before we see the final state and store it.
func (r *Reconciler) FinalizeKind(ctx context.Context, pr *pipelinev1.PipelineRun) knativereconciler.Event {
// Reconcile the pipelinerun to ensure that it is stored in the database
rerr := r.ReconcileKind(ctx, pr)

// If logsClient isn't nil, it means we have logging storage enabled
// and we can't use finalizers to coordinate deletion.
if r.logsClient != nil {
Expand Down Expand Up @@ -184,7 +187,7 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, pr *pipelinev1.PipelineRu
pr.Namespace, pr.Name, now.String(), storeDeadline.String(), requeueAfter.String())
return controller.NewRequeueAfter(requeueAfter)
}
if stored != "true" {
if rerr != nil || stored != "true" {
logging.FromContext(ctx).Debugf("stored annotation is not true on pipelinerun %s/%s, now: %s, storeDeadline: %s, requeueAfter: %s",
pr.Namespace, pr.Name, now.String(), storeDeadline.String(), requeueAfter.String())
return controller.NewRequeueAfter(requeueAfter)
Expand Down
5 changes: 4 additions & 1 deletion pkg/watcher/reconciler/taskrun/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tr *pipelinev1.TaskRun)
// that we see flowing through the system. If we don't add a finalizer, it could
// get cleaned up before we see the final state and store it.
func (r *Reconciler) FinalizeKind(ctx context.Context, tr *pipelinev1.TaskRun) knativereconciler.Event {
// Reconcile the taskrun to ensure that it is stored in the database
rerr := r.ReconcileKind(ctx, tr)

// If logsClient isn't nil, it means we have logging storage enabled
// and we can't use finalizers to coordinate deletion.
if r.logsClient != nil {
Expand Down Expand Up @@ -134,7 +137,7 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, tr *pipelinev1.TaskRun) k
tr.Namespace, tr.Name, now.String(), storeDeadline.String(), requeueAfter.String())
return controller.NewRequeueAfter(requeueAfter)
}
if stored != "true" {
if rerr != nil || stored != "true" {
logging.FromContext(ctx).Debugf("stored annotation is not true on taskrun %s/%s, now: %s, storeDeadline: %s",
tr.Namespace, tr.Name, now.String(), storeDeadline.String())
return controller.NewRequeueAfter(requeueAfter)
Expand Down

0 comments on commit a2b1e2d

Please sign in to comment.