From bff684d9517ceba7bdd97abdee3f462ba4c84989 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 18 Dec 2025 10:20:52 +0100 Subject: [PATCH] DRA ResourceClaim controller: update logging This provides a bit more information when the controller touches a ResourceClaim. --- pkg/controller/resourceclaim/controller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/controller/resourceclaim/controller.go b/pkg/controller/resourceclaim/controller.go index 7d51f28acd8..ff6fcc79b39 100644 --- a/pkg/controller/resourceclaim/controller.go +++ b/pkg/controller/resourceclaim/controller.go @@ -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) }