Skip to content

Commit

Permalink
Make sure to run parallel commands part of a composite command in par…
Browse files Browse the repository at this point in the history
…allel (#7075)

* Make sure to run parallel commands part of a composite command in parallel

* Display warnings in case there are errors when executing pre-stop events

* Fix the command_composite_parallel.go implementation by lowering the case of the sub-command names

Since this passed the Devfile validation logic, we should use the same logic as in command_composite.go
  • Loading branch information
rm3l authored Sep 6, 2023
1 parent 725a640 commit 00d3988
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/component/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (do *DeleteComponentClient) ExecutePreStopEvents(ctx context.Context, devfi
)
err = libdevfile.ExecPreStopEvents(ctx, devfileObj, handler)
if err != nil {
klog.V(4).Infof("Failed to execute %q event commands for component %q, cause: %v", libdevfile.PreStop, componentName, err.Error())
log.Warningf("Failed to execute %q event commands for component %q, cause: %v", libdevfile.PreStop, componentName, err.Error())
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/libdevfile/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ func newCommand(devfileObj parser.DevfileObj, devfileCmd v1alpha2.Command) (comm
case v1alpha2.CompositeCommandType:
if util.SafeGetBool(devfileCmd.Composite.Parallel) {
cmd = newParallelCompositeCommand(devfileObj, devfileCmd)
} else {
cmd = newCompositeCommand(devfileObj, devfileCmd)
}
cmd = newCompositeCommand(devfileObj, devfileCmd)

case v1alpha2.ExecCommandType:
cmd = newExecCommand(devfileObj, devfileCmd)
Expand Down
2 changes: 1 addition & 1 deletion pkg/libdevfile/command_composite_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (o *parallelCompositeCommand) Execute(ctx context.Context, handler Handler,
}
commandExecs := util.NewConcurrentTasks(len(o.command.Composite.Commands))
for _, devfileCmd := range o.command.Composite.Commands {
cmd, err2 := newCommand(o.devfileObj, allCommands[devfileCmd])
cmd, err2 := newCommand(o.devfileObj, allCommands[strings.ToLower(devfileCmd)])
if err2 != nil {
return err2
}
Expand Down

0 comments on commit 00d3988

Please sign in to comment.