Skip to content

Commit

Permalink
Make sure a canceled job does not start
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Jul 11, 2023
1 parent b24cfbe commit 3642685
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions prunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ func (r *PipelineRunner) ReadJob(id uuid.UUID, process func(j *PipelineJob)) err
func (r *PipelineRunner) startJob(job *PipelineJob) {
defer r.requestPersist()

if job.Canceled {
return
}

r.initScheduler(job)

graph, err := buildPipelineGraph(job.ID, job.Tasks, job.Variables)
Expand Down
4 changes: 2 additions & 2 deletions prunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ func TestPipelineRunner_CancelJob_WithQueuedJob(t *testing.T) {
pRunner, err := NewPipelineRunner(ctx, defs, func(j *PipelineJob) taskctl.Runner {
return &test.MockRunner{
OnRun: func(t *task.Task) error {
jobID := t.Variables.Get(taskctl.JobIDVariableName)
mx.Lock()
jobID := t.Variables.Get(taskctl.JobIDVariableName)
startedJobsIDs = append(startedJobsIDs, jobID.(string))
mx.Unlock()

Expand Down Expand Up @@ -934,7 +934,7 @@ func TestPipelineRunner_Shutdown_WithRunningJob_Forced(t *testing.T) {
QueueLimit: nil,
Tasks: map[string]definition.TaskDef{
"sleep": {
Script: []string{"sleep 1"},
Script: []string{"sleep 10"},
},
},
SourcePath: "fixtures",
Expand Down

0 comments on commit 3642685

Please sign in to comment.