@@ -72,7 +72,7 @@ func (t Engine) CreateWorkflow(ctx context.Context, opts CreateWorkflowOptions)
72
72
}
73
73
74
74
// Now build job definitions for each node in the graph
75
- jobs := make (map [string ]storage.Job , len (nodes ))
75
+ jobs := make (map [string ]* storage.Job , len (nodes ))
76
76
for _ , node := range nodes {
77
77
switch tn := node .(type ) {
78
78
case depsv2.BundleNode :
@@ -117,7 +117,7 @@ func (t Engine) CreateWorkflow(ctx context.Context, opts CreateWorkflowOptions)
117
117
}
118
118
}
119
119
120
- jobs [tn .Key ] = storage.Job {
120
+ jobs [tn .Key ] = & storage.Job {
121
121
Action : cnab .ActionInstall , // TODO(PEP003): eventually this needs to support all actions
122
122
Installation : inst ,
123
123
Depends : requiredJobs ,
@@ -211,8 +211,8 @@ func (t Engine) executeStage(ctx context.Context, w storage.Workflow, stageIndex
211
211
return fmt .Errorf ("could not sort jobs in stage" )
212
212
}
213
213
214
- availableJobs := make (chan storage.Job , len (s .Jobs ))
215
- completedJobs := make (chan storage.Job , len (s .Jobs ))
214
+ availableJobs := make (chan * storage.Job , len (s .Jobs ))
215
+ completedJobs := make (chan * storage.Job , len (s .Jobs ))
216
216
217
217
// Default the number of parallel jobs to the number of CPUs
218
218
// This gives us 1 CPU per invocation image.
@@ -235,6 +235,7 @@ func (t Engine) executeStage(ctx context.Context, w storage.Workflow, stageIndex
235
235
return
236
236
case job := <- availableJobs :
237
237
jobsInProgress .Go (func () error {
238
+ // TODO(PEP003) why do we have to look this up again?
238
239
return t .executeJob (ctx , s .Jobs [job .Key ], completedJobs )
239
240
})
240
241
}
@@ -283,15 +284,15 @@ func (t Engine) executeStage(ctx context.Context, w storage.Workflow, stageIndex
283
284
return err
284
285
}
285
286
286
- func (t Engine ) queueAvailableJobs (ctx context.Context , s storage.Stage , sortedNodes []depsv2.Node , availableJobs chan storage.Job ) bool {
287
+ func (t Engine ) queueAvailableJobs (ctx context.Context , s storage.Stage , sortedNodes []depsv2.Node , availableJobs chan * storage.Job ) bool {
287
288
// Walk through the graph in sorted order (bottom up)
288
289
// if the node's dependencies are all successful, schedule it
289
290
// as soon as it's not schedule, stop looking because none of the remainder will be either
290
291
var i int
291
292
for i = 0 ; i < len (sortedNodes ); i ++ {
292
293
node := sortedNodes [i ]
293
294
294
- job := node .(storage.Job )
295
+ job := node .(* storage.Job )
295
296
switch job .Status .Status {
296
297
case cnab .StatusFailed :
297
298
// stop scheduling more jobs
@@ -320,7 +321,7 @@ func (t Engine) queueAvailableJobs(ctx context.Context, s storage.Stage, sortedN
320
321
return i >= len (sortedNodes )
321
322
}
322
323
323
- func (t Engine ) executeJob (ctx context.Context , j storage.Job , jobs chan storage.Job ) error {
324
+ func (t Engine ) executeJob (ctx context.Context , j * storage.Job , jobs chan * storage.Job ) error {
324
325
ctx , span := tracing .StartSpan (ctx , tracing .ObjectAttribute ("job" , j ))
325
326
defer span .EndSpan ()
326
327
0 commit comments