Skip to content

Commit

Permalink
workaround for "runc list" returning "no such file or directory"
Browse files Browse the repository at this point in the history
  • Loading branch information
prezha committed Jan 17, 2024
1 parent d967689 commit 60d404a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/minikube/cruntime/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
"os/exec"
"path"
"strings"
"time"

"github.com/blang/semver/v4"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/util/retry"
)

// container maps to 'runc list -f json'
Expand Down Expand Up @@ -108,10 +110,23 @@ func listCRIContainers(cr CommandRunner, root string, o ListContainersOptions) (
}

args = append(args, "list", "-f", "json")
rr, err = cr.RunCmd(exec.Command("sudo", args...))
if err != nil {

// retry only on "no such file or directory" error returned by runc
// TODO (prezha): remove this workaround when #17976 is addressed upstream and we've updated to that runc version
list := func() error {
rr, err = cr.RunCmd(exec.Command("sudo", args...))
if errors.Is(err, os.ErrNotExist) {
klog.Infof("temporary error listing containers using runc (will retry): %v", err)
return err
}
// don't retry on non-error or any error other than os.ErrNotExist, but retain the underlying error and check thereafter
return nil
}
// return any underlying error
if rerr := retry.Expo(list, time.Millisecond*100, time.Second); rerr != nil || err != nil {
return nil, errors.Wrap(err, "runc")
}

content := rr.Stdout.Bytes()
klog.Infof("JSON = %s", content)
d := json.NewDecoder(bytes.NewReader(content))
Expand Down

0 comments on commit 60d404a

Please sign in to comment.