-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for workers accepting input on stdout and producing output on stdout. This adds add1c and add1d test coverage in pipelines.sh. add1d also adds python test coverage for pipelines. Also adds mix-and-match pipelines, where we mix-and-match calling conventions, and python vs bash. Improved pipeline error handling and error handling test coverage. Separate task failure watching from redirect logic. Signed-off-by: Nick Mitchell <[email protected]>
- Loading branch information
Showing
16 changed files
with
317 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package options | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/pkg/build" | ||
) | ||
|
||
func AddCallingConventionOptions(cmd *cobra.Command) *build.Options { | ||
opts := &build.Options{} | ||
AddCallingConventionOptionsTo(cmd, opts) | ||
cmd.MarkFlagRequired("calling-convention") | ||
return opts | ||
} | ||
|
||
func AddCallingConventionOptionsTo(cmd *cobra.Command, options *build.Options) { | ||
cmd.Flags().VarP(&options.CallingConvention, "calling-convention", "C", "Task input and output calling convention [files, stdio]") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package boot | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"lunchpail.io/pkg/be" | ||
"lunchpail.io/pkg/build" | ||
"lunchpail.io/pkg/ir/queue" | ||
s3 "lunchpail.io/pkg/runtime/queue" | ||
) | ||
|
||
func lookForTaskFailures(ctx context.Context, backend be.Backend, run queue.RunContext, opts build.LogOptions) error { | ||
client, err := s3.NewS3ClientForRun(ctx, backend, run.RunName) | ||
if err != nil { | ||
return err | ||
} | ||
defer client.Stop() | ||
|
||
if err := client.Mkdirp(run.Bucket); err != nil { | ||
return err | ||
} | ||
|
||
failures := run.AsFileForAnyWorker(queue.FinishedWithFailed) // we want to be notified if a task fails in *any* worker | ||
objc, errc := client.Listen(run.Bucket, failures, "", false) | ||
|
||
done := false | ||
for !done { | ||
select { | ||
case err := <-errc: | ||
if err == nil || strings.Contains(err.Error(), "EOF") { | ||
done = true | ||
} else { | ||
fmt.Fprintln(os.Stderr, err) | ||
} | ||
case object := <-objc: | ||
// Oops, a task failed. Fetch the stderr and show it. | ||
if opts.Verbose { | ||
fmt.Fprintf(os.Stderr, "Got indication of task failure %s\n", object) | ||
} | ||
|
||
// We need to find the FinishedWithStderr file | ||
// that corresponds to the given object, which | ||
// is an AssignedAndFinished file. To do so, | ||
// we can parse the object to extract the task | ||
// instance (`ForObjectTask`) and then use | ||
// that `fortask` to templatize the | ||
// FinishedWithCode | ||
forobject, err := run.ForObject(queue.FinishedWithFailed, object) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
errorContent, err := client.Get(run.Bucket, forobject.AsFile(queue.FinishedWithStderr)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fmt.Errorf("\033[0;31m" + errorContent + "\033[0m\n") | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package hlir | ||
|
||
import "fmt" | ||
|
||
type CallingConvention string | ||
|
||
const ( | ||
CallingConventionFiles CallingConvention = "files" | ||
CallingConventionStdio = "stdio" | ||
) | ||
|
||
func lookup(maybe string) (CallingConvention, error) { | ||
switch maybe { | ||
case string(CallingConventionFiles): | ||
return CallingConventionFiles, nil | ||
case string(CallingConventionStdio): | ||
return CallingConventionStdio, nil | ||
} | ||
|
||
return "", fmt.Errorf("Unsupported calling convention %s\n", maybe) | ||
} | ||
|
||
// String is used both by fmt.Print and by Cobra in help text | ||
func (cc *CallingConvention) String() string { | ||
return string(*cc) | ||
} | ||
|
||
// Set must have pointer receiver so it doesn't change the value of a copy | ||
func (cc *CallingConvention) Set(v string) error { | ||
p, err := lookup(v) | ||
if err != nil { | ||
return err | ||
} | ||
*cc = p | ||
return nil | ||
} | ||
|
||
// Type is only used in help text | ||
func (cc *CallingConvention) Type() string { | ||
return "CallingConvention" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.