in controllers/seataserver_controller.go [273:295]
func (r *SeataServerReconciler) cleanupOrphanPVCs(ctx context.Context, s *seatav1alpha1.SeataServer) (err error) {
// this check should make sure we do not delete the PVCs before the STS has scaled down
if s.Status.ReadyReplicas == s.Spec.Replicas {
pvcCount, err := r.getPVCCount(ctx, s)
if err != nil {
return err
}
r.Log.Info(fmt.Sprintf("cleanupOrphanPVCs with PVC count %d and ReadyReplicas count %d", pvcCount, s.Status.ReadyReplicas))
if pvcCount > int(s.Spec.Replicas) {
pvcList, err := r.getPVCList(ctx, s)
if err != nil {
return err
}
for _, pvcItem := range pvcList.Items {
// delete only Orphan PVCs
if utils.IsPVCOrphan(pvcItem.Name, s.Spec.Replicas) {
r.deletePVC(ctx, pvcItem)
}
}
}
}
return nil
}