From b52f107bde3474aa23540a77f0a0b432e3fbfec5 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Tue, 27 Jun 2023 16:40:12 +0000 Subject: [PATCH] Update log messages Signed-off-by: Gabriel Adrian Samfira --- runner/pool/pool.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 284b2983..1fad2e5a 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -1461,17 +1461,17 @@ func (r *basePoolManager) consumeQueuedJobs() error { poolsCache := poolsForTags{} - log.Printf("found %d queued jobs for %s", len(queued), r.helper.String()) + log.Printf("[Pool mgr %s] found %d queued jobs for %s", r.helper.String(), len(queued), r.helper.String()) for _, job := range queued { if job.LockedBy != uuid.Nil && job.LockedBy.String() != r.ID() { // Job was handled by us or another entity. - log.Printf("[Pool mgr ID %s] job %d is locked by %s", r.ID(), job.ID, job.LockedBy.String()) + log.Printf("[Pool mgr %s] job %d is locked by %s", r.helper.String(), job.ID, job.LockedBy.String()) continue } if time.Since(job.UpdatedAt) < time.Second*20 { // give the idle runners a chance to pick up the job. - log.Printf("job %d was updated less than 20 seconds ago. Skipping", job.ID) + log.Printf("[Pool mgr %s] job %d was updated less than 20 seconds ago. Skipping", r.helper.String(), job.ID) continue } @@ -1487,15 +1487,15 @@ func (r *basePoolManager) consumeQueuedJobs() error { return errors.Wrap(err, "deleting job") } default: - log.Printf("failed to fetch job information from github: %q (status code: %d)", err, ghResp.StatusCode) + log.Printf("[Pool mgr %s] failed to fetch job information from github: %q (status code: %d)", r.helper.String(), err, ghResp.StatusCode) } } - log.Printf("error fetching workflow info: %q", err) + log.Printf("[Pool mgr %s] error fetching workflow info: %q", r.helper.String(), err) continue } if workflow.GetStatus() != "queued" { - log.Printf("job is no longer in queued state on github. New status is: %s", workflow.GetStatus()) + log.Printf("[Pool mgr %s] job is no longer in queued state on github. New status is: %s", r.helper.String(), workflow.GetStatus()) job.Action = workflow.GetStatus() job.Status = workflow.GetStatus() job.Conclusion = workflow.GetConclusion() @@ -1512,7 +1512,7 @@ func (r *basePoolManager) consumeQueuedJobs() error { job.RunnerGroupID = *workflow.RunnerGroupID } if _, err := r.store.CreateOrUpdateJob(r.ctx, job); err != nil { - log.Printf("failed to update job status: %q", err) + log.Printf("[Pool mgr %s] failed to update job status: %q", r.helper.String(), err) } continue } @@ -1520,7 +1520,7 @@ func (r *basePoolManager) consumeQueuedJobs() error { // Job is still queued in our db and in github. Unlock it and try again. if err := r.store.UnlockJob(r.ctx, job.ID, r.ID()); err != nil { // TODO: Implament a cache? Should we return here? - log.Printf("failed to unlock job %d: %q", job.ID, err) + log.Printf("[Pool mgr %s] failed to unlock job %d: %q", r.helper.String(), job.ID, err) continue } } @@ -1530,7 +1530,7 @@ func (r *basePoolManager) consumeQueuedJobs() error { // TODO(gabriel-samfira): create an in-memory state of existing runners that we can easily // check for existing pending or idle runners. If we can't find any, attempt to allocate another // runner. - log.Printf("[Pool mgr ID %s] job %d is locked by us", r.ID(), job.ID) + log.Printf("[Pool mgr %s] job %d is locked by us", r.helper.String(), job.ID) continue } @@ -1538,20 +1538,20 @@ func (r *basePoolManager) consumeQueuedJobs() error { if !ok { potentialPools, err := r.store.FindPoolsMatchingAllTags(r.ctx, r.helper.PoolType(), r.helper.ID(), job.Labels) if err != nil { - log.Printf("[Pool mgr ID %s] error finding pools matching labels: %s", r.ID(), err) + log.Printf("[Pool mgr %s] error finding pools matching labels: %s", r.helper.String(), err) continue } poolRR = poolsCache.Add(job.Labels, potentialPools) } if poolRR.Len() == 0 { - log.Printf("[Pool mgr ID %s] could not find pools with labels %s", r.ID(), strings.Join(job.Labels, ",")) + log.Printf("[Pool mgr %s] could not find pools with labels %s", r.helper.String(), strings.Join(job.Labels, ",")) continue } runnerCreated := false if err := r.store.LockJob(r.ctx, job.ID, r.ID()); err != nil { - log.Printf("[Pool mgr ID %s] could not lock job %d: %s", r.ID(), job.ID, err) + log.Printf("[Pool mgr %s] could not lock job %d: %s", r.helper.String(), job.ID, err) continue } @@ -1561,31 +1561,31 @@ func (r *basePoolManager) consumeQueuedJobs() error { for { pool, err := poolRR.Next() if err != nil { - log.Printf("[PoolRR] could not find a pool to create a runner for job %d: %s", job.ID, err) + log.Printf("[PoolRR %s] could not find a pool to create a runner for job %d: %s", r.helper.String(), job.ID, err) break } - log.Printf("[PoolRR] attempting to create a runner in pool %s for job %d", pool.ID, job.ID) + log.Printf("[PoolRR %s] attempting to create a runner in pool %s for job %d", r.helper.String(), pool.ID, job.ID) if err := r.addRunnerToPool(pool, jobLabels); err != nil { log.Printf("[PoolRR] could not add runner to pool %s: %s", pool.ID, err) continue } - log.Printf("[PoolRR] a new runner was added to pool %s as a response to queued job %d", pool.ID, job.ID) + log.Printf("[PoolRR %s] a new runner was added to pool %s as a response to queued job %d", r.helper.String(), pool.ID, job.ID) runnerCreated = true break } if !runnerCreated { - log.Printf("could not create a runner for job %d; unlocking", job.ID) + log.Printf("[Pool mgr %s] could not create a runner for job %d; unlocking", r.helper.String(), job.ID) if err := r.store.UnlockJob(r.ctx, job.ID, r.ID()); err != nil { - log.Printf("failed to unlock job: %d", job.ID) + log.Printf("[Pool mgr %s] failed to unlock job: %d", r.helper.String(), job.ID) return errors.Wrap(err, "unlocking job") } } } if err := r.store.DeleteCompletedJobs(r.ctx); err != nil { - log.Printf("failed to delete completed jobs: %q", err) + log.Printf("[Pool mgr %s] failed to delete completed jobs: %q", r.helper.String(), err) } return nil }