From d47e3fda78cd80b183353b83aad5a41b91a300a5 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Thu, 18 Jul 2024 15:36:20 +1000 Subject: [PATCH] fix: include lease keys in scheduled task logs (#2114) --- backend/controller/scheduledtask/scheduledtask.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/controller/scheduledtask/scheduledtask.go b/backend/controller/scheduledtask/scheduledtask.go index 6c2b52954d..84dd6c8090 100644 --- a/backend/controller/scheduledtask/scheduledtask.go +++ b/backend/controller/scheduledtask/scheduledtask.go @@ -129,12 +129,13 @@ func (s *Scheduler) run(ctx context.Context) { } // If the job is singly homed, see if we can acquire the lease. if job.singlyHomed && job.lease == nil { - lease, _, err := s.leaser.AcquireLease(ctx, leases.SystemKey("scheduledtask", job.name), time.Second*10, optional.None[any]()) + key := leases.SystemKey("scheduledtask", job.name) + lease, _, err := s.leaser.AcquireLease(ctx, key, time.Second*10, optional.None[any]()) if err != nil { if errors.Is(err, leases.ErrConflict) { - logger.Scope(job.name).Tracef("Lease is held by another controller, will try again shortly.") + logger.Scope(job.name).Tracef("Scheduled task lease is held by another controller, will try again shortly: %v", key) } else { - logger.Scope(job.name).Debugf("Failed to acquire lease: %s", err) + logger.Scope(job.name).Debugf("Failed to acquire scheduled task lease %v: %s", key, err) } job.next = s.clock.Now().Add(job.retry.Duration()) continue