@@ -366,27 +366,42 @@ func (d *Director) executePluginsAsDAG(ctx context.Context, request *schedulingt
366366 // Execute the DAG
367367
368368 // Channels to signal plugin execution completion.
369- pluginExecuted := map [string ]chan struct {}{}
369+ pluginExecuted := make ( map [string ]chan error )
370370 nameToNode := map [string ]PrepareDataPlugin {}
371371 for _ , plugin := range plugins {
372- pluginExecuted [plugin .TypedName ().String ()] = make (chan struct {} )
372+ pluginExecuted [plugin .TypedName ().String ()] = make (chan error )
373373 nameToNode [plugin .TypedName ().String ()] = plugin
374374 }
375375
376376 for pluginName , dependents := range dag {
377377 // Execute plugins based on dependencies.
378378 // Wait for the dependencies to complete before executing a plugin.
379- go func () {
379+ go func () error {
380380 for _ , dep := range dependents {
381- <- pluginExecuted [dep ]
381+ err , open := <- pluginExecuted [dep ]
382+ if ! open {
383+ continue
384+ }
385+ if err != nil {
386+ // If a dependency failed, propagate the error and do not execute this plugin.
387+ pluginExecuted [pluginName ] <- fmt .Errorf ("dependency plugin %s failed: %w" , dep , err )
388+ return err
389+ }
382390 }
383- nameToNode [pluginName ].PrepareRequestData (ctx , request , pods )
384391 // Signal that the plugin has been executed.
385- close (pluginExecuted [pluginName ])
392+ defer close (pluginExecuted [pluginName ])
393+
394+ return nameToNode [pluginName ].PrepareRequestData (ctx , request , pods )
386395 }()
387396 }
388397 for pluginName := range dag {
389- <- pluginExecuted [pluginName ]
398+ err , open := <- pluginExecuted [pluginName ]
399+ if ! open {
400+ continue
401+ }
402+ if err != nil {
403+ return err
404+ }
390405 }
391406 return nil
392407}
0 commit comments