Skip to content

Commit 17ca61d

Browse files
committed
Introduce cmdTimeout argument to configure previously hard-coded timeout
1 parent ba0e02c commit 17ca61d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/capture/executils/shell.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"sync"
1212
"time"
1313

14+
"yc-agent/internal/config"
1415
"yc-agent/internal/logger"
1516
)
1617

@@ -196,7 +197,10 @@ func CommandCombinedOutputToWriter(writer io.Writer, cmd Command, hookers ...Hoo
196197
}()
197198

198199
// execution timer
199-
timerDuration := 1 * time.Minute
200+
timerDuration := config.GlobalConfig.CmdTimeout
201+
if timerDuration == 0 {
202+
timerDuration = 60 * time.Second // fallback to default if not configured, or accidentally set to 0
203+
}
200204
timer := time.NewTimer(timerDuration)
201205
select {
202206
case <-timer.C:

internal/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type Options struct {
9494
EdScript string `yaml:"edScript" usage:"Extended Data: Path to a custom script that collects extended diagnostics data"`
9595
EdDataFolder string `yaml:"edDataFolder" usage:"Extended Data: Directory path where artifacts generated by (-edScript) will be stored and collected."`
9696

97+
CmdTimeout time.Duration `yaml:"cmdTimeout" usage:"Command execution timeout duration (e.g., 1m, 30s). Default is 60 seconds."`
9798
HttpClientTimeout time.Duration `yaml:"httpClientTimeout" usage:"HTTP client timeout for API requests (e.g., 1m, 30s). Default is 60 seconds."`
9899
}
99100

@@ -176,6 +177,7 @@ func defaultConfig() Config {
176177
DeferDelete: true,
177178
AppLogLineCount: 10000,
178179
TDCaptureDuration: 0 * time.Second, // Setting here 0 seconds as default since handling it in jstack.go
180+
CmdTimeout: 60 * time.Second,
179181
HttpClientTimeout: 60 * time.Second,
180182
},
181183
}

0 commit comments

Comments
 (0)