mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
DRA ResourceClaim controller: update logging
This provides a bit more information when the controller touches a ResourceClaim.
This commit is contained in:
parent
21bf85de15
commit
bff684d951
1 changed files with 6 additions and 2 deletions
|
|
@ -944,6 +944,7 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.V(5).Info("Removed consumers", "claim", klog.KRef(namespace, name), "currentCount", len(claim.Status.ReservedFor), "allocated", claim.Status.Allocation != nil)
|
||||
|
||||
// Now also remove the finalizer if it is not needed anymore.
|
||||
// Note that the index may have changed as a result of the UpdateStatus call.
|
||||
|
|
@ -953,6 +954,7 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err
|
|||
if _, err := ec.kubeClient.ResourceV1().ResourceClaims(claim.Namespace).Update(ctx, claim, metav1.UpdateOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
logger.V(5).Info("Removed finalizer after removing consumers", "claim", klog.KRef(namespace, name))
|
||||
}
|
||||
} else if builtinControllerFinalizer >= 0 && claim.DeletionTimestamp != nil && len(remaining) == 0 {
|
||||
claim := claim.DeepCopy()
|
||||
|
|
@ -966,6 +968,7 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.V(5).Info("Removed allocation because not needed", "claim", klog.KRef(namespace, name))
|
||||
}
|
||||
// Whether it was allocated or not, remove the finalizer to unblock removal.
|
||||
claim.Finalizers = slices.Delete(claim.Finalizers, builtinControllerFinalizer, builtinControllerFinalizer+1)
|
||||
|
|
@ -973,6 +976,7 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger.V(5).Info("Removed finalizer because not needed", "claim", klog.KRef(namespace, name))
|
||||
}
|
||||
|
||||
if len(remaining) == 0 {
|
||||
|
|
@ -989,11 +993,11 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err
|
|||
if pod.UID != podUID || isPodDone(pod) {
|
||||
// We are certain that the owning pod is not going to need
|
||||
// the claim and therefore remove the claim.
|
||||
logger.V(5).Info("Deleting unused generated claim", "claim", klog.KObj(claim), "pod", klog.KObj(pod))
|
||||
err := ec.kubeClient.ResourceV1().ResourceClaims(claim.Namespace).Delete(ctx, claim.Name, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete claim %s: %w", klog.KObj(claim), err)
|
||||
return fmt.Errorf("delete unused generated claim %s: %w", klog.KObj(claim), err)
|
||||
}
|
||||
logger.V(5).Info("Deleted unused generated claim", "claim", klog.KObj(claim), "pod", klog.KObj(pod))
|
||||
} else {
|
||||
logger.V(6).Info("Wrong pod content, not deleting claim", "claim", klog.KObj(claim), "podUID", podUID, "podContent", pod)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue