@@ -176,19 +176,19 @@ func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
176176
177177 var triggeredBy int64
178178 defer func () {
179- if jobParams .ID == 0 {
179+ if jobParams .WorkflowJobID == 0 {
180180 return
181181 }
182182 // we're updating the job in the database, regardless of whether it was successful or not.
183183 // or if it was meant for this pool or not. Github will send the same job data to all hierarchies
184184 // that have been configured to work with garm. Updating the job at all levels should yield the same
185185 // outcome in the db.
186- _ , err := r .store .GetJobByID (r .ctx , jobParams .ID )
186+ _ , err := r .store .GetJobByID (r .ctx , jobParams .WorkflowJobID )
187187 if err != nil {
188188 if ! errors .Is (err , runnerErrors .ErrNotFound ) {
189189 slog .With (slog .Any ("error" , err )).ErrorContext (
190190 r .ctx , "failed to get job" ,
191- "job_id" , jobParams .ID )
191+ "job_id" , jobParams .WorkflowJobID )
192192 return
193193 }
194194 // This job is new to us. Check if we have a pool that can handle it.
@@ -203,10 +203,10 @@ func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
203203
204204 if _ , jobErr := r .store .CreateOrUpdateJob (r .ctx , jobParams ); jobErr != nil {
205205 slog .With (slog .Any ("error" , jobErr )).ErrorContext (
206- r .ctx , "failed to update job" , "job_id" , jobParams .ID )
206+ r .ctx , "failed to update job" , "job_id" , jobParams .WorkflowJobID )
207207 }
208208
209- if triggeredBy != 0 && jobParams .ID != triggeredBy {
209+ if triggeredBy != 0 && jobParams .WorkflowJobID != triggeredBy {
210210 // The triggeredBy value is only set by the "in_progress" webhook. The runner that
211211 // transitioned to in_progress was created as a result of a different queued job. If that job is
212212 // still queued and we don't remove the lock, it will linger until the lock timeout is reached.
@@ -970,7 +970,7 @@ func (r *basePoolManager) paramsWorkflowJobToParamsJob(job params.WorkflowJob) (
970970 }
971971
972972 jobParams := params.Job {
973- ID : job .WorkflowJob .ID ,
973+ WorkflowJobID : job .WorkflowJob .ID ,
974974 Action : job .Action ,
975975 RunID : job .WorkflowJob .RunID ,
976976 Status : job .WorkflowJob .Status ,
@@ -1106,10 +1106,10 @@ func (r *basePoolManager) scaleDownOnePool(ctx context.Context, pool params.Pool
11061106
11071107 for _ , job := range queued {
11081108 if time .Since (job .CreatedAt ).Minutes () > 10 && pool .HasRequiredLabels (job .Labels ) {
1109- if err := r .store .DeleteJob (ctx , job .ID ); err != nil && ! errors .Is (err , runnerErrors .ErrNotFound ) {
1109+ if err := r .store .DeleteJob (ctx , job .WorkflowJobID ); err != nil && ! errors .Is (err , runnerErrors .ErrNotFound ) {
11101110 slog .With (slog .Any ("error" , err )).ErrorContext (
11111111 ctx , "failed to delete job" ,
1112- "job_id" , job .ID )
1112+ "job_id" , job .WorkflowJobID )
11131113 }
11141114 }
11151115 }
@@ -1760,7 +1760,7 @@ func (r *basePoolManager) consumeQueuedJobs() error {
17601760 // Job was handled by us or another entity.
17611761 slog .DebugContext (
17621762 r .ctx , "job is locked" ,
1763- "job_id" , job .ID ,
1763+ "job_id" , job .WorkflowJobID ,
17641764 "locking_entity" , job .LockedBy .String ())
17651765 continue
17661766 }
@@ -1769,20 +1769,20 @@ func (r *basePoolManager) consumeQueuedJobs() error {
17691769 // give the idle runners a chance to pick up the job.
17701770 slog .DebugContext (
17711771 r .ctx , "job backoff not reached" , "backoff_interval" , r .controllerInfo .MinimumJobAgeBackoff ,
1772- "job_id" , job .ID )
1772+ "job_id" , job .WorkflowJobID )
17731773 continue
17741774 }
17751775
17761776 if time .Since (job .UpdatedAt ) >= time .Minute * 10 {
17771777 // Job is still queued in our db, 10 minutes after a matching runner
17781778 // was spawned. Unlock it and try again. A different job may have picked up
17791779 // the runner.
1780- if err := r .store .UnlockJob (r .ctx , job .ID , r .ID ()); err != nil {
1780+ if err := r .store .UnlockJob (r .ctx , job .WorkflowJobID , r .ID ()); err != nil {
17811781 // nolint:golangci-lint,godox
17821782 // TODO: Implament a cache? Should we return here?
17831783 slog .With (slog .Any ("error" , err )).ErrorContext (
17841784 r .ctx , "failed to unlock job" ,
1785- "job_id" , job .ID )
1785+ "job_id" , job .WorkflowJobID )
17861786 continue
17871787 }
17881788 }
@@ -1795,7 +1795,7 @@ func (r *basePoolManager) consumeQueuedJobs() error {
17951795 // runner.
17961796 slog .DebugContext (
17971797 r .ctx , "job is locked by us" ,
1798- "job_id" , job .ID )
1798+ "job_id" , job .WorkflowJobID )
17991799 continue
18001800 }
18011801
@@ -1816,29 +1816,29 @@ func (r *basePoolManager) consumeQueuedJobs() error {
18161816 }
18171817
18181818 runnerCreated := false
1819- if err := r .store .LockJob (r .ctx , job .ID , r .ID ()); err != nil {
1819+ if err := r .store .LockJob (r .ctx , job .WorkflowJobID , r .ID ()); err != nil {
18201820 slog .With (slog .Any ("error" , err )).ErrorContext (
18211821 r .ctx , "could not lock job" ,
1822- "job_id" , job .ID )
1822+ "job_id" , job .WorkflowJobID )
18231823 continue
18241824 }
18251825
18261826 jobLabels := []string {
1827- fmt .Sprintf ("%s=%d" , jobLabelPrefix , job .ID ),
1827+ fmt .Sprintf ("%s=%d" , jobLabelPrefix , job .WorkflowJobID ),
18281828 }
18291829 for i := 0 ; i < poolRR .Len (); i ++ {
18301830 pool , err := poolRR .Next ()
18311831 if err != nil {
18321832 slog .With (slog .Any ("error" , err )).ErrorContext (
18331833 r .ctx , "could not find a pool to create a runner for job" ,
1834- "job_id" , job .ID )
1834+ "job_id" , job .WorkflowJobID )
18351835 break
18361836 }
18371837
18381838 slog .InfoContext (
18391839 r .ctx , "attempting to create a runner in pool" ,
18401840 "pool_id" , pool .ID ,
1841- "job_id" , job .ID )
1841+ "job_id" , job .WorkflowJobID )
18421842 if err := r .addRunnerToPool (pool , jobLabels ); err != nil {
18431843 slog .With (slog .Any ("error" , err )).ErrorContext (
18441844 r .ctx , "could not add runner to pool" ,
@@ -1847,19 +1847,19 @@ func (r *basePoolManager) consumeQueuedJobs() error {
18471847 }
18481848 slog .DebugContext (r .ctx , "a new runner was added as a response to queued job" ,
18491849 "pool_id" , pool .ID ,
1850- "job_id" , job .ID )
1850+ "job_id" , job .WorkflowJobID )
18511851 runnerCreated = true
18521852 break
18531853 }
18541854
18551855 if ! runnerCreated {
18561856 slog .WarnContext (
18571857 r .ctx , "could not create a runner for job; unlocking" ,
1858- "job_id" , job .ID )
1859- if err := r .store .UnlockJob (r .ctx , job .ID , r .ID ()); err != nil {
1858+ "job_id" , job .WorkflowJobID )
1859+ if err := r .store .UnlockJob (r .ctx , job .WorkflowJobID , r .ID ()); err != nil {
18601860 slog .With (slog .Any ("error" , err )).ErrorContext (
18611861 r .ctx , "failed to unlock job" ,
1862- "job_id" , job .ID )
1862+ "job_id" , job .WorkflowJobID )
18631863 return errors .Wrap (err , "unlocking job" )
18641864 }
18651865 }
0 commit comments