Issues

Select view

Select search mode

 
50 of

[BUG] Redundant deletion by issuing `Delete` without checking resource existence

Description

Description

We find the MongoDB controller often issues deletion even when the resources do not exist. For example, in `deleteCfgIfNeeded`:

The controller directly issues deletion of config sts without checking its existence (and ignores `IsNotFound`). When sharding is always disabled, such deletion makes no change to the cluster since the config sts never exists. Given that `Get` (from local cache) is usually much faster than `Delete` (to the apiserver), checking the sts existence by issuing `Get` before issuing `Delete` of the sts would be better. Note that in the same `deleteCfgIfNeeded`, svc is deleted in this manner:

In addition, this approach also helps to check the local indexer staleness. If `Get` confirms the resource existence but `Delete` returns `NotFound` error, it indicates potential staleness in the local indexer.

Similar problems also exist in other methods like `deleteMongos`.

Fix

We are willing to send a PR for this issue. As mentioned before, `Get` before `Delete` would be better here.

Environment

None

Smart Checklist

Details

Assignee

Reporter

Affects versions

Priority

Smart Checklist

Created April 17, 2021 at 3:45 PM
Updated March 5, 2024 at 4:55 PM

Activity

Show:

Lalit ChoudharyMay 6, 2021 at 11:08 AM

Hi

Thank you for the report.

Yes, please send PR and Dev will review.