Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/schemas/flowfile_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
},
"timeout": {
"description": "The maximum amount of time the executable is allowed to run before being terminated.\nThe timeout is specified in Go duration format (e.g. 30s, 5m, 1h).\n",
"type": "string",
"default": "30m0s"
"type": "string"
},
"verb": {
"$ref": "#/definitions/ExecutableVerb",
Expand Down
2 changes: 1 addition & 1 deletion docs/types/flowfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Executables are the building blocks of workflows and are used to define the acti
| `request` | | [ExecutableRequestExecutableType](#ExecutableRequestExecutableType) | <no value> | |
| `serial` | | [ExecutableSerialExecutableType](#ExecutableSerialExecutableType) | <no value> | |
| `tags` | | [CommonTags](#CommonTags) | [] | |
| `timeout` | The maximum amount of time the executable is allowed to run before being terminated. The timeout is specified in Go duration format (e.g. 30s, 5m, 1h). | `string` | 30m0s | |
| `timeout` | The maximum amount of time the executable is allowed to run before being terminated. The timeout is specified in Go duration format (e.g. 30s, 5m, 1h). | `string` | <no value> | |
| `verb` | | [ExecutableVerb](#ExecutableVerb) | exec | ✘ |
| `visibility` | | [CommonVisibility](#CommonVisibility) | <no value> | |

Expand Down
2 changes: 1 addition & 1 deletion internal/cache/executable_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func executablesFromFile(logger io.Logger, fileBase, filePath string) (*executab
if err != nil {
return nil, errors.Wrapf(err, "unable to parse timeout duration %s", value)
}
exec.Timeout = dur
exec.Timeout = &dur
case fileparser.VerbConfigurationKey:
exec.Verb = executable.Verb(value)
case fileparser.NameConfigurationKey:
Expand Down
6 changes: 3 additions & 3 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Exec(
return fmt.Errorf("compatible runner not found for executable %s", executable.ID())
}

if executable.Timeout == 0 {
if executable.Timeout == nil {
return assignedRunner.Exec(ctx, executable, eng, inputEnv)
}

Expand All @@ -55,8 +55,8 @@ func Exec(
select {
case err := <-done:
return err
case <-time.After(executable.Timeout):
return fmt.Errorf("timeout after %v", executable.Timeout)
case <-time.After(*executable.Timeout):
return fmt.Errorf("timeout after %v", *executable.Timeout)
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ var _ = Describe("Runner", func() {

It("should return error when execution times out", func() {
ctx := &context.Context{}
timeout := 250 * time.Millisecond
exec := &executable.Executable{
Name: "test-exec",
Timeout: 250 * time.Millisecond,
Timeout: &timeout,
}
promptedEnv := make(map[string]string)

Expand Down
2 changes: 1 addition & 1 deletion tools/builder/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func ExecWithTimeout(opts ...Option) *executable.Executable {
Name: name,
Visibility: privateExecVisibility(),
Description: docstring,
Timeout: timeout,
Timeout: &timeout,
Exec: &executable.ExecExecutableType{
Cmd: fmt.Sprintf("sleep %d", int(timeout.Seconds()+10)),
},
Expand Down
2 changes: 1 addition & 1 deletion types/executable/executable.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions types/executable/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
//go:generate go run github.com/atombender/go-jsonschema@v0.16.0 -et --only-models -p executable -o executable.gen.go --capitalization URI --capitalization URL executable_schema.yaml

const (
TmpDirLabel = "f:tmp"
DefaultTimeout = 30 * time.Minute
TmpDirLabel = "f:tmp"
)

type ExecutableList []*Executable
Expand Down Expand Up @@ -231,11 +230,10 @@ func (e *Executable) SetDefaults() {
e.Visibility = &v
}

if e.Timeout == 0 {
e.Timeout = DefaultTimeout
if e.Timeout == nil {
if v, ok := os.LookupEnv(TimeoutOverrideEnv); ok {
if d, err := time.ParseDuration(v); err == nil {
e.Timeout = d
e.Timeout = &d
}
}
}
Expand Down Expand Up @@ -540,7 +538,7 @@ func (e *Executable) MarshalJSON() ([]byte, error) {
}{
Alias: (*Alias)(e),
}
if e.Timeout != 0 {
if e.Timeout != nil {
aux.Timeout = e.Timeout.String()
}
return json.Marshal(aux)
Expand All @@ -562,7 +560,7 @@ func (e *Executable) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
e.Timeout = duration
e.Timeout = &duration
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion types/executable/executable_md.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func execMarkdown(e *Executable) string {
if e.Visibility != nil {
mkdwn += fmt.Sprintf("**Visibility:** %s\n", *e.Visibility)
}
if e.Timeout != 0 {
if e.Timeout != nil {
mkdwn += fmt.Sprintf("**Timeout:** %s\n", e.Timeout.String())
}
if len(e.Aliases) > 0 {
Expand Down
1 change: 0 additions & 1 deletion types/executable/executable_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ properties:
description: |
The maximum amount of time the executable is allowed to run before being terminated.
The timeout is specified in Go duration format (e.g. 30s, 5m, 1h).
default: 30m0s
#### Executable context fields
workspace:
type: string
Expand Down
Loading