Skip to content

Commit

Permalink
Avoid using cached client when getting 'Namespace' object on delete e…
Browse files Browse the repository at this point in the history
…vent
  • Loading branch information
shirsa committed Mar 25, 2021
1 parent 9494345 commit 7c3b659
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/util/lockedresourcecontroller/resource-reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ func (p *resourceModifiedPredicate) Delete(e event.DeleteEvent) bool {
// we return true only if the enclosing namespace is not also being deleted
if e.Object.GetNamespace() != "" {
namespace := corev1.Namespace{}
err := p.lrr.GetClient().Get(context.TODO(), types.NamespacedName{Name: e.Object.GetNamespace()}, &namespace)
// Use non-cached client since client's cache may be namespaced
err := p.lrr.GetAPIReader().Get(context.TODO(), types.NamespacedName{Name: e.Object.GetNamespace()}, &namespace)
if err != nil {
p.lrr.log.Error(err, "unable to retrieve ", "namespace", "e.Meta.GetNamespace()")
return false
Expand Down

0 comments on commit 7c3b659

Please sign in to comment.