Skip to content

Commit 446133f

Browse files
committed
move default timeout setting to resource
1 parent f517579 commit 446133f

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

pkg/config/resources/exec/provider.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ func (p *Provider) createRemoteExec(outputPath string) error {
205205
group = p.config.RunAs.Group
206206
}
207207

208-
if p.config.Timeout == "" {
209-
p.config.Timeout = "300s"
210-
}
211-
212208
timeout, err := time.ParseDuration(p.config.Timeout)
213209
if err != nil {
214210
p.log.Error("Unable to parse timeout duration", "ref", p.config.Meta.Name, "timeout", p.config.Timeout, "error", err)
@@ -314,13 +310,8 @@ func (p *Provider) createLocalExec(outputPath string) (int, error) {
314310
// create the folders for logs and pids
315311
logPath := filepath.Join(utils.LogsDir(), fmt.Sprintf("exec_%s.log", p.config.Meta.Name))
316312

317-
// do we have a duration to parse otherwise set default
318-
if p.config.Timeout == "" {
319-
p.config.Timeout = "300s"
320-
} else {
321-
if p.config.Daemon {
322-
p.log.Warn("Timeout will be ignored when exec is running in daemon mode")
323-
}
313+
if p.config.Timeout != "" && p.config.Daemon {
314+
p.log.Warn("Timeout will be ignored when exec is running in daemon mode")
324315
}
325316

326317
timeout, err := time.ParseDuration(p.config.Timeout)

pkg/config/resources/exec/resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func (e *Exec) Process() error {
5757
}
5858
}
5959

60+
if e.Timeout == "" && !e.Daemon {
61+
e.Timeout = "300s"
62+
}
63+
6064
cs, err := utils.ChecksumFromInterface(e.Script)
6165
if err != nil {
6266
return fmt.Errorf("unable to generate checksum for script: %s", err)

0 commit comments

Comments
 (0)