Skip to content

Commit 25cbb6e

Browse files
authored
Merge pull request #7410 from medyagh/adjust_warn_slow
adjust warn if slow for ps and volume
2 parents f54c87f + a0263c2 commit 25cbb6e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Diff for: pkg/drivers/kic/oci/oci.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,26 @@ func ContainerID(ociBinary string, nameOrID string) (string, error) {
234234
}
235235

236236
// WarnIfSlow runs an oci command, warning about performance issues
237-
func WarnIfSlow(arg ...string) ([]byte, error) {
238-
killTime := 15 * time.Second
237+
func WarnIfSlow(args ...string) ([]byte, error) {
238+
killTime := 19 * time.Second
239239
warnTime := 2 * time.Second
240240

241+
if args[1] == "volume" || args[1] == "ps" { // volume and ps requires more time than inspect
242+
killTime = 30 * time.Second
243+
warnTime = 3 * time.Second
244+
}
245+
241246
ctx, cancel := context.WithTimeout(context.Background(), killTime)
242247
defer cancel()
243248

244249
start := time.Now()
245-
glog.Infof("executing with %s timeout: %v", arg, killTime)
246-
cmd := exec.CommandContext(ctx, arg[0], arg[1:]...)
250+
glog.Infof("executing with %s timeout: %v", args, killTime)
251+
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
247252
stdout, err := cmd.Output()
248253
d := time.Since(start)
249254
if d > warnTime {
250255
out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": strings.Join(cmd.Args, " "), "duration": d})
251-
out.ErrT(out.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": arg[0]})
256+
out.ErrT(out.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": args[0]})
252257
}
253258

254259
if ctx.Err() == context.DeadlineExceeded {

0 commit comments

Comments
 (0)