Skip to content

Commit

Permalink
fix(KFLUXBUGS-1921): auto-release false RPA should end reconcile
Browse files Browse the repository at this point in the history
If a ReleasePlanAdmission is found with auto-release set to false, it
will continually requeue the error because it is not a not found error.
Instead, the Release should be marked as validation false and
reconciliation should end.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
  • Loading branch information
johnbieren committed Dec 2, 2024
1 parent c3f18e0 commit e586d10
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/release/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ func (a *adapter) validatePipelineDefined() *controller.ValidationResult {
}
releasePlanAdmission, err := a.loader.GetActiveReleasePlanAdmissionFromRelease(a.ctx, a.client, a.release)
if err != nil {
if errors.IsNotFound(err) {
if errors.IsNotFound(err) || strings.Contains(err.Error(), "with auto-release label set to false") {
a.release.MarkValidationFailed(err.Error())
return &controller.ValidationResult{Valid: false}
}
Expand Down
54 changes: 54 additions & 0 deletions controllers/release/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,60 @@ var _ = Describe("Release adapter", Ordered, func() {
Expect(result.Err).NotTo(HaveOccurred())
})

It("should return false if ReleasePlan has no Pipeline Set and ReleasePlanAdmission is not found", func() {
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
{
ContextKey: loader.ReleasePlanAdmissionContextKey,
Err: errors.NewNotFound(schema.GroupResource{}, ""),
},
{
ContextKey: loader.ReleasePlanContextKey,
Resource: &v1alpha1.ReleasePlan{
ObjectMeta: metav1.ObjectMeta{
Name: "release-plan",
Namespace: "default",
},
Spec: v1alpha1.ReleasePlanSpec{
Application: application.Name,
ReleaseGracePeriodDays: 6,
Target: "default",
},
},
},
})

result := adapter.validatePipelineDefined()
Expect(result.Valid).To(BeFalse())
Expect(result.Err).NotTo(HaveOccurred())
})

It("should return false if ReleasePlan has no Pipeline Set and ReleasePlanAdmission is set to auto-release false", func() {
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
{
ContextKey: loader.ReleasePlanAdmissionContextKey,
Err: fmt.Errorf("with auto-release label set to false"),
},
{
ContextKey: loader.ReleasePlanContextKey,
Resource: &v1alpha1.ReleasePlan{
ObjectMeta: metav1.ObjectMeta{
Name: "release-plan",
Namespace: "default",
},
Spec: v1alpha1.ReleasePlanSpec{
Application: application.Name,
ReleaseGracePeriodDays: 6,
Target: "default",
},
},
},
})

result := adapter.validatePipelineDefined()
Expect(result.Valid).To(BeFalse())
Expect(result.Err).NotTo(HaveOccurred())
})

It("should set the target in the release status to the ReleasePlan namespace if no target is defined", func() {
adapter.ctx = toolkit.GetMockedContext(ctx, []toolkit.MockData{
{
Expand Down

0 comments on commit e586d10

Please sign in to comment.