Skip to content

exportServices/SSL cleanup should ignore Delete NotFound after cached read #2531

Description

@ChaoHuang2018

Hi Percona MongoDB Operator maintainers,

I noticed three remaining cleanup delete paths where a cached read/list can be followed by a live Delete that returns NotFound.

I saw #1751 and the merged fix PR #2389, which addressed repeated redundant delete calls by introducing DeleteIfExists in several cleanup paths. This issue is narrower: in the paths below, the controller has already read or listed a target object, but if that object is gone by the time the delete reaches the API server, the delete-side NotFound is still returned as a cleanup error.

In current main, exportServices lists ServiceExport objects and deletes each one when multicluster support is disabled:

pkg/controller/perconaservermongodb/service.go:130-L147

This branch returns any delete error. A later stale ServiceExport cleanup branch in the same function already ignores k8serrors.IsNotFound(err):

pkg/controller/perconaservermongodb/service.go:173-L176

The SSL certificate rotation path has the same delete-result shape. It gets a Secret, compares CA data, then deletes the Secret when it should be recreated:

pkg/controller/perconaservermongodb/ssl.go:232-L256

The old-CA cleanup path also gets an old Secret and deletes it when the merged CA is already present:

pkg/controller/perconaservermongodb/ssl.go:365-L389

A possible interleaving is:

a cleanup path reads or lists an object that should be deleted
the object is deleted by a previous reconcile attempt or another controller action
the cache has not observed that deletion yet
the cleanup path still calls Delete(ctx, object)
Delete returns NotFound from the API server
the cleanup path returns an error even though the object is already absent

For these paths, absence of the target object seems to be the desired cleanup state. Would it be reasonable to use client.IgnoreNotFound(err) or an explicit k8serrors.IsNotFound(err) check around these delete calls, while still reporting other delete failures?

Chao

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions