Skip to content

Commit

Permalink
Clean up RunsToCompletion interface
Browse files Browse the repository at this point in the history
The RunsToCompletion interface was introduced so that PipelineRuns and Runs
could conform to a common interface for CloudEvents and subsequently removed.

This commit removes the redundant function PipelineRun.IsTimedOut (redundant with PipelineRun.HasTimedOut).
PipelineRun.HasTimedOut was introduced so that PipelineRun would implement RunsToCompletion.
"HasTimedOut" was kept (as opposed to "IsTimedOut") for the sake of consistency with TaskRun and Run.

It also removes stale references to RunsToCompletion. No functional changes.
  • Loading branch information
lbernick authored and tekton-robot committed Jan 13, 2022
1 parent 56a9b03 commit 1401ab7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions pkg/apis/pipeline/v1beta1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ func (pr *PipelineRun) GetNamespacedName() types.NamespacedName {
return types.NamespacedName{Namespace: pr.Namespace, Name: pr.Name}
}

// IsTimedOut returns true if a pipelinerun has exceeded its spec.Timeout based on its status.Timeout
func (pr *PipelineRun) IsTimedOut() bool {
return pr.HasTimedOut()
}

// HasTimedOut returns true if a pipelinerun has exceeded its spec.Timeout based on its status.Timeout
func (pr *PipelineRun) HasTimedOut() bool {
pipelineTimeout := pr.Spec.Timeout
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ func TestPipelineRunHasTimedOut(t *testing.T) {
}},
}

if pr.IsTimedOut() != tc.expected {
t.Fatalf("Expected isTimedOut to be %t", tc.expected)
if pr.HasTimedOut() != tc.expected {
t.Fatalf("Expected HasTimedOut to be %t", tc.expected)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/taskrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (trs *TaskRunStatus) GetStartedReason() string {
}

// GetRunningReason returns the reason set to the "Succeeded" condition when
// the RunsToCompletion starts running. This is used indicate that the resource
// the TaskRun starts running. This is used indicate that the resource
// could be validated is starting to perform its job.
func (trs *TaskRunStatus) GetRunningReason() string {
return TaskRunReasonRunning.String()
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/cloudevent/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ type objectWithCondition interface {
// ObjectMetaAccessor requires a GetObjectMeta that returns the ObjectMeta
metav1.ObjectMetaAccessor

// GetStatusCondition returns a ConditionAccessor for the status of the RunsToCompletion
// GetStatusCondition returns a ConditionAccessor for the status of the objectWithCondition
GetStatusCondition() apis.ConditionAccessor
}
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func (c *Reconciler) processRunTimeouts(ctx context.Context, pr *v1beta1.Pipelin
}
for _, rprt := range pipelineState {
if rprt.IsCustomTask() {
if rprt.Run != nil && !rprt.Run.IsCancelled() && (pr.IsTimedOut() || (rprt.Run.HasTimedOut() && !rprt.Run.IsDone())) {
if rprt.Run != nil && !rprt.Run.IsCancelled() && (pr.HasTimedOut() || (rprt.Run.HasTimedOut() && !rprt.Run.IsDone())) {
logger.Infof("Cancelling run task: %s due to timeout.", rprt.RunName)
err := cancelRun(ctx, rprt.RunName, pr.Namespace, c.PipelineClientSet)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/pipelinerunstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (facts *PipelineRunFacts) GetPipelineConditionStatus(pr *v1beta1.PipelineRu
// 2. All tasks are done and at least one has failed or has been cancelled -> Failed
// 3. All tasks are done or are skipped (i.e. condition check failed).-> Success
// 4. A Task or Condition is running right now or there are things left to run -> Running
if pr.IsTimedOut() {
if pr.HasTimedOut() {
return &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Expand Down

0 comments on commit 1401ab7

Please sign in to comment.