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
Hi Percona MongoDB Operator maintainers,
I noticed three remaining cleanup delete paths where a cached read/list can be followed by a live
Deletethat returnsNotFound.I saw #1751 and the merged fix PR #2389, which addressed repeated redundant delete calls by introducing
DeleteIfExistsin 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-sideNotFoundis still returned as a cleanup error.In current
main,exportServiceslistsServiceExportobjects and deletes each one when multicluster support is disabled:pkg/controller/perconaservermongodb/service.go:130-L147This branch returns any delete error. A later stale
ServiceExportcleanup branch in the same function already ignoresk8serrors.IsNotFound(err):pkg/controller/perconaservermongodb/service.go:173-L176The 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-L256The 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-L389A possible interleaving is:
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 explicitk8serrors.IsNotFound(err)check around these delete calls, while still reporting other delete failures?Chao