diff --git a/internal/controllers/reconciliation/controller.go b/internal/controllers/reconciliation/controller.go index 69e9e10c..df2b2bcc 100644 --- a/internal/controllers/reconciliation/controller.go +++ b/internal/controllers/reconciliation/controller.go @@ -209,6 +209,7 @@ func (c *Controller) Reconcile(ctx context.Context, req *reconstitution.Request) current.GetDeletionTimestamp() != nil || (resource.Deleted() && comp.Annotations["eno.azure.io/deletion-strategy"] == "orphan") // orphaning should be reflected on the status. c.writeBuffer.PatchStatusAsync(ctx, &resource.ManifestRef, patchResourceState(deleted, ready)) + logger.V(0).Info("Wrote patch status to the buffer", "deleted", deleted, "ready", ready) if ready == nil { return ctrl.Result{RequeueAfter: wait.Jitter(c.readinessPollInterval, 0.1)}, nil } diff --git a/internal/flowcontrol/writebuffer.go b/internal/flowcontrol/writebuffer.go index 229421de..9d060d06 100644 --- a/internal/flowcontrol/writebuffer.go +++ b/internal/flowcontrol/writebuffer.go @@ -10,6 +10,7 @@ import ( "golang.org/x/time/rate" "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" ctrl "sigs.k8s.io/controller-runtime" @@ -171,7 +172,14 @@ func (w *ResourceSliceWriteBuffer) updateSlice(ctx context.Context, sliceNSN typ if patch == nil { continue } - + // NOTE: This is slow and purely for debugging. + u := &unstructured.Unstructured{} + if err := u.UnmarshalJSON([]byte(slice.Spec.Resources[update.SlicedResource.Index].Manifest)); err != nil { + logger = logger.WithValues("index", update.SlicedResource.Index) + } else { + logger = logger.WithValues("resource-name", u.GetName(), "resource-kind", u.GroupVersionKind().Kind) + } + logger.V(1).Info("will patch status for resource") patches = append(patches, &jsonPatch{ Op: "replace", Path: fmt.Sprintf("/status/resources/%d", update.SlicedResource.Index), diff --git a/internal/reconstitution/queueprocessor.go b/internal/reconstitution/queueprocessor.go index c7bb91c0..50272417 100644 --- a/internal/reconstitution/queueprocessor.go +++ b/internal/reconstitution/queueprocessor.go @@ -38,6 +38,8 @@ func (q *queueProcessor) processQueueItem(ctx context.Context) bool { logger := q.Logger.WithValues("compositionName", req.Composition.Name, "compositionNamespace", req.Composition.Namespace, "resourceKind", req.Resource.Kind, "resourceName", req.Resource.Name, "resourceNamespace", req.Resource.Namespace) ctx = logr.NewContext(ctx, logger) + logger.Info("processing queue item") + defer logger.Info("done with queue item") result, err := q.Handler.Reconcile(ctx, &req) if err != nil { @@ -60,6 +62,7 @@ func (q *queueProcessor) processQueueItem(ctx context.Context) bool { return true } + logger.Info("forgetting queue item") q.Queue.Forget(item) return true }