Merge pull request #8457 from priyawadhwa/errormessage
Improve logging for cloud shellpull/8467/head
commit
c387bf9724
|
@ -89,14 +89,15 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
|
|||
|
||||
killTime := 19 * time.Second // this will be applied only if warnSlow is true
|
||||
warnTime := 2 * time.Second
|
||||
ctx, cancel := context.WithTimeout(context.Background(), killTime)
|
||||
defer cancel()
|
||||
|
||||
if cmd.Args[1] == "volume" || cmd.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()
|
||||
|
||||
if warn { // convert exec.Command to with context
|
||||
cmdWithCtx := exec.CommandContext(ctx, cmd.Args[0], cmd.Args[1:]...)
|
||||
cmdWithCtx.Stdout = cmd.Stdout //copying the original command
|
||||
|
@ -138,7 +139,7 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
|
|||
}
|
||||
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
return rr, fmt.Errorf("%q timed out after %s", rr.Command(), killTime)
|
||||
return rr, context.DeadlineExceeded
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package oci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -27,6 +28,7 @@ import (
|
|||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
"k8s.io/minikube/pkg/util/retry"
|
||||
|
||||
"fmt"
|
||||
|
@ -73,10 +75,11 @@ func DeleteContainersByLabel(ociBin string, label string) []error {
|
|||
|
||||
// DeleteContainer deletes a container by ID or Name
|
||||
func DeleteContainer(ociBin string, name string) error {
|
||||
|
||||
_, err := ContainerStatus(ociBin, name)
|
||||
if err != nil {
|
||||
glog.Errorf("%s daemon seems to be stuck. Please try restarting your %s. Will try to delete anyways: %v", ociBin, ociBin, err)
|
||||
if err == context.DeadlineExceeded {
|
||||
out.WarningT("{{.ocibin}} is taking an unsually long time to respond, consider restarting {{.ocibin}}", out.V{"ociBin": ociBin})
|
||||
} else if err != nil {
|
||||
glog.Warningf("error getting container status, will try to delete anyways: %v", err)
|
||||
}
|
||||
// try to delete anyways
|
||||
if err := ShutDown(ociBin, name); err != nil {
|
||||
|
|
Loading…
Reference in New Issue