[BUG] Mongodb operator does not delete PVC after scaling-down leading to resource leak

Description

Description

The mongodb operator updates the stateful set size if the ReplsetSpec.size gets changed (either by user-issued scaling or disabling arbiter). If ReplsetSpec.size is smaller than before, the size of the statefulset will decrease and the pod will be deleted. However, the controller does not delete the PVC used by the deleted pod, which leads to storage resource leak.

Fix

During each reconcile, we can make the operator list all the PVC used by mongodb and check whether its owner pod is still running. If not, the operator can delete the PVC as long as delete-psmdb-pvc finalizer is present.

We are willing to send a PR to deal with the resource leak problem.

Environment

None

Smart Checklist

Activity

Done

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

Smart Checklist

Created October 30, 2021 at 4:41 PM
Updated March 5, 2024 at 4:46 PM
Resolved June 3, 2022 at 2:52 PM