diff --git a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go index 4eb3c92a4c6..b08816ec218 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go @@ -81,7 +81,6 @@ type configStore interface { // Reconciler implements controller.Reconciler for Configuration resources. type Reconciler struct { *reconciler.Base - // listers index properties about resources pipelineRunLister listers.PipelineRunLister pipelineLister listers.PipelineLister @@ -167,6 +166,11 @@ func (c *Reconciler) Reconcile(ctx context.Context, key string) error { pr := original.DeepCopy() if !pr.HasStarted() { pr.Status.InitializeConditions() + // In case node time was not synchronized, when controller has been scheduled to other nodes. + if pr.Status.StartTime.Sub(pr.CreationTimestamp.Time) < 0 { + c.Logger.Warnf("PipelineRun %s createTimestamp %s is after the pipelineRun started %s", pr.GetRunKey(), pr.CreationTimestamp, pr.Status.StartTime) + pr.Status.StartTime = &pr.CreationTimestamp + } // start goroutine to track pipelinerun timeout only startTime is not set go c.timeoutHandler.WaitPipelineRun(pr, pr.Status.StartTime) } else { diff --git a/pkg/reconciler/v1alpha1/taskrun/taskrun.go b/pkg/reconciler/v1alpha1/taskrun/taskrun.go index f0191b112a7..f761fa3f9c9 100644 --- a/pkg/reconciler/v1alpha1/taskrun/taskrun.go +++ b/pkg/reconciler/v1alpha1/taskrun/taskrun.go @@ -157,6 +157,11 @@ func (c *Reconciler) Reconcile(ctx context.Context, key string) error { // If the TaskRun is just starting, this will also set the starttime, // from which the timeout will immediately begin counting down. tr.Status.InitializeConditions() + // In case node time was not synchronized, when controller has been scheduled to other nodes. + if tr.Status.StartTime.Sub(tr.CreationTimestamp.Time) < 0 { + c.Logger.Warnf("TaskRun %s createTimestamp %s is after the taskRun started %s", tr.GetRunKey(), tr.CreationTimestamp, tr.Status.StartTime) + tr.Status.StartTime = &tr.CreationTimestamp + } if tr.IsDone() { c.timeoutHandler.Release(tr)