From 8f51d7de588b526e8a5ded2e58b54fefd51993bc Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 3 Apr 2020 19:08:41 -0700 Subject: [PATCH 1/3] adjust warn if slow for ps and volume --- pkg/drivers/kic/oci/oci.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index a1265dbe24ba..08bb981e282e 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -234,21 +234,26 @@ func ContainerID(ociBinary string, nameOrID string) (string, error) { } // WarnIfSlow runs an oci command, warning about performance issues -func WarnIfSlow(arg ...string) ([]byte, error) { +func WarnIfSlow(args ...string) ([]byte, error) { killTime := 15 * time.Second warnTime := 2 * time.Second + if args[1] == "volume" || args[1] == "ps" { // volume and ps requires more time than inspect + killTime = 30 * time.Second + warnTime = 3 * time.Second + } + ctx, cancel := context.WithTimeout(context.Background(), killTime) defer cancel() start := time.Now() - glog.Infof("executing with %s timeout: %v", arg, killTime) - cmd := exec.CommandContext(ctx, arg[0], arg[1:]...) + glog.Infof("executing with %s timeout: %v", args, killTime) + cmd := exec.CommandContext(ctx, args[0], args[1:]...) stdout, err := cmd.Output() d := time.Since(start) if d > warnTime { out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": strings.Join(cmd.Args, " "), "duration": d}) - out.ErrT(out.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": arg[0]}) + out.ErrT(out.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": args[0]}) } if ctx.Err() == context.DeadlineExceeded { From a62d611e0b27e513f0f3dd662bd0377f54aa92cb Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 3 Apr 2020 19:09:45 -0700 Subject: [PATCH 2/3] adjust kill time --- pkg/drivers/kic/oci/oci.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 08bb981e282e..1db19fa73e2e 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -235,7 +235,7 @@ func ContainerID(ociBinary string, nameOrID string) (string, error) { // WarnIfSlow runs an oci command, warning about performance issues func WarnIfSlow(args ...string) ([]byte, error) { - killTime := 15 * time.Second + killTime := 18 * time.Second warnTime := 2 * time.Second if args[1] == "volume" || args[1] == "ps" { // volume and ps requires more time than inspect From a0263c2513607485bb06c1840167a078b0a29730 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 3 Apr 2020 20:50:26 -0700 Subject: [PATCH 3/3] adjust more --- pkg/drivers/kic/oci/oci.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 1db19fa73e2e..29b6ddbd9bbf 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -235,7 +235,7 @@ func ContainerID(ociBinary string, nameOrID string) (string, error) { // WarnIfSlow runs an oci command, warning about performance issues func WarnIfSlow(args ...string) ([]byte, error) { - killTime := 18 * time.Second + killTime := 19 * time.Second warnTime := 2 * time.Second if args[1] == "volume" || args[1] == "ps" { // volume and ps requires more time than inspect