Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error log when resource is deleted #640

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (r *repository) getObject(ctx context.Context, name string, namespace strin
)
if err != nil {
namespacedName := getNamespacedName(name, namespace)
log.Error(err, "failed to get object from api server", "object", namespacedName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might still be worth logging the error when the error is not a NotFound error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an internal method and all of the public methods which call it already handle that error logging.

return fmt.Errorf("failed to get object [%s] from api server: %w", namespacedName, err)
}

Expand Down
20 changes: 15 additions & 5 deletions pkg/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,12 @@ spec:
)
cl.GetReturns(apiError)
})
It("returns a nil result without error", func() {
It("returns a nil result without error and without logging an error", func() {
delivery, err := repo.GetDelivery(ctx, "my-delivery")
Expect(err).NotTo(HaveOccurred())
Expect(delivery).To(BeNil())

Expect(out.Contents()).To(BeEmpty())
})
})

Expand Down Expand Up @@ -996,10 +998,12 @@ spec:
})

Context("workload doesnt exist", func() {
It("returns nil workload", func() {
It("returns nil workload without logging an error", func() {
workload, err := repo.GetWorkload(ctx, "workload-that-does-not-exist-name", "workload-namespace")
Expect(err).NotTo(HaveOccurred())
Expect(workload).To(BeNil())

Expect(out.Contents()).To(BeEmpty())
})
})
})
Expand All @@ -1022,10 +1026,12 @@ spec:
})

Context("deliverable doesnt exist", func() {
It("returns nil deliverable", func() {
It("returns nil deliverable without logging an error", func() {
deliverable, err := repo.GetDeliverable(ctx, "deliverable-that-does-not-exist-name", "deliverable-namespace")
Expect(err).NotTo(HaveOccurred())
Expect(deliverable).To(BeNil())

Expect(out.Contents()).To(BeEmpty())
})
})
})
Expand All @@ -1048,10 +1054,12 @@ spec:
})

Context("runnable doesnt exist", func() {
It("returns nil runnable", func() {
It("returns nil runnable without logging an error", func() {
runnable, err := repo.GetRunnable(ctx, "runnable-that-does-not-exist-name", "runnable-namespace")
Expect(err).NotTo(HaveOccurred())
Expect(runnable).To(BeNil())

Expect(out.Contents()).To(BeEmpty())
})
})
})
Expand All @@ -1073,10 +1081,12 @@ spec:
})

Context("supply chain doesnt exist", func() {
It("returns no error", func() {
It("returns no error without logging an error", func() {
sc, err := repo.GetSupplyChain(ctx, "sc-that-does-not-exist-name")
Expect(err).ToNot(HaveOccurred())
Expect(sc).To(BeNil())

Expect(out.Contents()).To(BeEmpty())
})
})
})
Expand Down