Skip to content

Commit e813d0a

Browse files
fix 01
Signed-off-by: Sean Conroy <sconroy@redhat.com>
1 parent 6c427aa commit e813d0a

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

api/v1alpha1/release_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ func (r *Release) MarkCurrentManagedPipelineAttemptProcessed() {
475475
}
476476

477477
attempt := r.GetCurrentManagedPipelineAttempt()
478+
if attempt == nil {
479+
return
480+
}
481+
478482
attempt.Status = AttemptSucceededReason
479483
attempt.CompletionTime = &metav1.Time{Time: time.Now()}
480484

@@ -728,6 +732,10 @@ func (r *Release) MarkCurrentManagedPipelineAttemptFailed(message, failureReason
728732
}
729733

730734
attempt := r.GetCurrentManagedPipelineAttempt()
735+
if attempt == nil {
736+
return
737+
}
738+
731739
attempt.Status = AttemptFailedReason
732740
attempt.CompletionTime = &metav1.Time{Time: time.Now()}
733741
attempt.FailureReason = failureReason

controllers/release/adapter.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,12 @@ func (a *adapter) EnsureManagedPipelineIsProcessed() (controller.OperationResult
548548
return controller.RequeueOnErrorOrContinue(a.client.Status().Patch(a.ctx, a.release, patch))
549549
}
550550

551-
pipelineRun, err := a.loader.GetReleasePipelineRun(a.ctx, a.client, a.release, metadata.ManagedPipelineType)
551+
// Let the completion operation handle retry when the current attempt has failed
552+
if a.release.IsCurrentManagedPipelineAttemptFailed() {
553+
return controller.ContinueProcessing()
554+
}
555+
556+
pipelineRun, err := a.loader.GetReleasePipelineRunAttempt(a.ctx, a.client, a.release, a.release.GetManagedPipelineRetryCount())
552557
if err != nil && !errors.IsNotFound(err) {
553558
return controller.RequeueWithError(err)
554559
}

controllers/release/adapter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ var _ = Describe("Release adapter", Ordered, func() {
11511151
It("should requeue with error if fetching the Release managed pipeline returns an error besides not found", func() {
11521152
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
11531153
{
1154-
ContextKey: loader.ReleasePipelineRunContextKey,
1154+
ContextKey: loader.ReleasePipelineRunAttemptContextKey,
11551155
Err: fmt.Errorf("some error"),
11561156
},
11571157
})
@@ -1224,7 +1224,7 @@ var _ = Describe("Release adapter", Ordered, func() {
12241224
It("should continue if the PipelineRun exists and the release managed pipeline processing has started", func() {
12251225
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
12261226
{
1227-
ContextKey: loader.ReleasePipelineRunContextKey,
1227+
ContextKey: loader.ReleasePipelineRunAttemptContextKey,
12281228
Resource: &tektonv1.PipelineRun{
12291229
ObjectMeta: metav1.ObjectMeta{
12301230
Name: "pipeline-run",
@@ -1249,7 +1249,7 @@ var _ = Describe("Release adapter", Ordered, func() {
12491249
It("should register the processing data if the PipelineRun already exists", func() {
12501250
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
12511251
{
1252-
ContextKey: loader.ReleasePipelineRunContextKey,
1252+
ContextKey: loader.ReleasePipelineRunAttemptContextKey,
12531253
Resource: &tektonv1.PipelineRun{
12541254
ObjectMeta: metav1.ObjectMeta{
12551255
Name: "pipeline-run",

0 commit comments

Comments
 (0)