Record run input directory and retry failed runs with original inputs
This commit is contained in:
+21
-2
@@ -73,6 +73,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.BoolVar(&o.wait, "wait", false, "In JSON mode, wait for a terminal run state")
|
||||
case "runs":
|
||||
f.StringVar(&o.name, "pipeline", "", "Filter by exact pipeline name or ID")
|
||||
case "retry":
|
||||
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
|
||||
f.BoolVar(&o.wait, "wait", false, "Wait for the new run to finish")
|
||||
}
|
||||
f.Usage = func() {
|
||||
fmt.Fprintf(a.Out, "Usage: pipelines %s\n", usage[command])
|
||||
@@ -404,7 +407,7 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("template %q not found", key)
|
||||
case "inspect", "cancel":
|
||||
case "inspect", "cancel", "retry":
|
||||
value, err := one()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -417,10 +420,21 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
if command == "cancel" {
|
||||
typeName = protocol.CancelRun
|
||||
}
|
||||
r, err := call(protocol.Message{Type: typeName, RunID: id})
|
||||
key := ""
|
||||
if command == "retry" {
|
||||
typeName = protocol.RetryRun
|
||||
key = o.key
|
||||
if key == "" {
|
||||
key = fmt.Sprintf("retry-%d-%d", os.Getpid(), time.Now().UnixNano())
|
||||
}
|
||||
}
|
||||
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if command == "retry" {
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
return a.output(r.RunDetail)
|
||||
case "rpc":
|
||||
path, err := one()
|
||||
@@ -647,6 +661,11 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return a.finishRun(ctx, r, o, call)
|
||||
}
|
||||
|
||||
func (a App) finishRun(ctx context.Context, r protocol.Message, o *options, call callFunc) error {
|
||||
var err error
|
||||
if o.wait {
|
||||
if r.RunDetail == nil {
|
||||
return fmt.Errorf("server did not return run detail")
|
||||
|
||||
Reference in New Issue
Block a user