Skip to content

Commit

Permalink
Update not found error message wording (#463)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Oct 18, 2023
1 parent 7020ae2 commit c9d387e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
20 changes: 10 additions & 10 deletions internal/controllers/operator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("package '%s' not found", pkgName)))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' found", pkgName)))

By("fetching updated operator after reconcile")
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
Expand All @@ -92,7 +92,7 @@ var _ = Describe("Operator Controller Test", func() {
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found", pkgName)))
})
})
When("the operator specifies a version that does not exist", func() {
Expand All @@ -114,7 +114,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '0.50.0' found", pkgName)))

By("fetching updated operator after reconcile")
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
Expand All @@ -128,7 +128,7 @@ var _ = Describe("Operator Controller Test", func() {
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '0.50.0' found", pkgName)))
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
Expand Down Expand Up @@ -760,7 +760,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))

By("fetching updated operator after reconcile")
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
Expand All @@ -774,7 +774,7 @@ var _ = Describe("Operator Controller Test", func() {
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
Expand Down Expand Up @@ -803,7 +803,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("package '%s' in channel '%s' not found", pkgName, pkgChan)))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' found in channel '%s'", pkgName, pkgChan)))

By("fetching updated operator after reconcile")
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
Expand All @@ -817,7 +817,7 @@ var _ = Describe("Operator Controller Test", func() {
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' in channel '%s' not found", pkgName, pkgChan)))
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found in channel '%s'", pkgName, pkgChan)))
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
Expand Down Expand Up @@ -849,7 +849,7 @@ var _ = Describe("Operator Controller Test", func() {
By("running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
Expect(res).To(Equal(ctrl.Result{}))
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))

By("fetching updated operator after reconcile")
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
Expand All @@ -863,7 +863,7 @@ var _ = Describe("Operator Controller Test", func() {
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
Expect(cond).NotTo(BeNil())
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
Expand Down
12 changes: 4 additions & 8 deletions internal/resolution/variablesources/required_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,14 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context) ([]dep
}

func (r *RequiredPackageVariableSource) notFoundError() error {
// TODO: update this error message when/if we decide to support version ranges as opposed to fixing the version
// context: we originally wanted to support version ranges and take the highest version that satisfies the range
// during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range
// support under the covers in case we decide to pivot back.
if r.versionRange != "" && r.channelName != "" {
return fmt.Errorf("package '%s' at version '%s' in channel '%s' not found", r.packageName, r.versionRange, r.channelName)
return fmt.Errorf("no package '%s' matching version '%s' found in channel '%s'", r.packageName, r.versionRange, r.channelName)
}
if r.versionRange != "" {
return fmt.Errorf("package '%s' at version '%s' not found", r.packageName, r.versionRange)
return fmt.Errorf("no package '%s' matching version '%s' found", r.packageName, r.versionRange)
}
if r.channelName != "" {
return fmt.Errorf("package '%s' in channel '%s' not found", r.packageName, r.channelName)
return fmt.Errorf("no package '%s' found in channel '%s'", r.packageName, r.channelName)
}
return fmt.Errorf("package '%s' not found", r.packageName)
return fmt.Errorf("no package '%s' found", r.packageName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var _ = Describe("RequiredPackageVariableSource", func() {
Expect(err).NotTo(HaveOccurred())
_, err = rpvs.GetVariables(context.TODO())
Expect(err).To(HaveOccurred())
Expect(err).To(MatchError("package 'test-package' not found"))
Expect(err).To(MatchError("no package 'test-package' found"))
})

It("should return an error if catalog client errors", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var _ = Describe("Operator Install", func() {
g.Expect(cond).ToNot(BeNil())
g.Expect(cond.Status).To(Equal(metav1.ConditionFalse))
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
g.Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
g.Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found", pkgName)))
}).Should(Succeed())

By("creating an Operator catalog with the desired package")
Expand Down

0 comments on commit c9d387e

Please sign in to comment.