operator
operator copied to clipboard
When the VMAgent CR is deleted, the corresponding StatefulSet is left behind.
Problem
When a VMAgent CR is deleted, the expected behavior is that the deletion of the CR will be blocked until the associated StatefulSet is deleted. However, there's a chance that the CR gets deleted while the StatefulSet is still being blocked by the finalizer.
Reproduction Steps
- Create a VMAgent CR.
- Quickly delete the VMAgent CR.
Root Cause Analysis
- Once the StatefulSet corresponding to the CR is created, the operator's informer has not yet received the StatefulSet creation event.
- If the CR is deleted at this point, the operator's cache client is unable to retrieve the StatefulSet, leading to the assumption that the finalizer has already been removed, as seen in the code from vmagent.go
- This results in the removal of the CR's finalizer, as indicated by the code from common.go