Update status before returning err

This commit is contained in:
Cici Huang
2025-03-06 08:10:46 -08:00
parent f12dbc31a9
commit ae9dcc0a75
2 changed files with 25 additions and 2 deletions

View File

@@ -553,6 +553,11 @@ func (d *namespacedResourcesDeleter) deleteAllContent(ctx context.Context, ns *v
// Check if any pods remain before proceeding to delete other resources
if numRemainingTotals.gvrToNumRemaining[podsGVR] > 0 {
logger.V(5).Info("Namespace controller - pods still remain, delaying deletion of other resources", "namespace", namespace)
if hasChanged := conditionUpdater.Update(ns); hasChanged {
if _, err = d.nsClient.UpdateStatus(ctx, ns, metav1.UpdateOptions{}); err != nil {
utilruntime.HandleError(fmt.Errorf("couldn't update status condition for namespace %q: %w", namespace, err))
}
}
return estimate, utilerrors.NewAggregate(errs)
}
}