@@ -234,21 +234,26 @@ func ContainerID(ociBinary string, nameOrID string) (string, error) {
234
234
}
235
235
236
236
// 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
239
239
warnTime := 2 * time .Second
240
240
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
+
241
246
ctx , cancel := context .WithTimeout (context .Background (), killTime )
242
247
defer cancel ()
243
248
244
249
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 :]... )
247
252
stdout , err := cmd .Output ()
248
253
d := time .Since (start )
249
254
if d > warnTime {
250
255
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 ]})
252
257
}
253
258
254
259
if ctx .Err () == context .DeadlineExceeded {
0 commit comments