Merge pull request #8499 from medyagh/sol_msg_cpucount
docker/podman: add advice for cpu count errorpull/8555/head
commit
18e89bbca2
|
@ -155,15 +155,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
||||||
ds, alts, specified := selectDriver(existing)
|
ds, alts, specified := selectDriver(existing)
|
||||||
starter, err := provisionWithDriver(cmd, ds, existing)
|
starter, err := provisionWithDriver(cmd, ds, existing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, oci.ErrWindowsContainers) {
|
maybeExitWithAdvice(err)
|
||||||
out.ErrLn("")
|
|
||||||
out.ErrT(out.Conflict, "Your Docker Desktop container os type is Windows but Linux is required.")
|
|
||||||
out.T(out.Warning, "Please change Docker settings to use Linux containers instead of Windows containers.")
|
|
||||||
out.T(out.Documentation, "https://minikube.sigs.k8s.io/docs/drivers/docker/#verify-docker-container-type-is-linux")
|
|
||||||
exit.UsageT(`You can verify your Docker container type by running:
|
|
||||||
{{.command}}
|
|
||||||
`, out.V{"command": "docker info --format '{{.OSType}}'"})
|
|
||||||
}
|
|
||||||
if specified {
|
if specified {
|
||||||
// If the user specified a driver, don't fallback to anything else
|
// If the user specified a driver, don't fallback to anything else
|
||||||
exit.WithError("error provisioning host", err)
|
exit.WithError("error provisioning host", err)
|
||||||
|
@ -1042,3 +1034,35 @@ func getKubernetesVersion(old *config.ClusterConfig) string {
|
||||||
}
|
}
|
||||||
return nv
|
return nv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// maybeExitWithAdvice before exiting will try to check for different error types and provide advice
|
||||||
|
func maybeExitWithAdvice(err error) {
|
||||||
|
if errors.Is(err, oci.ErrWindowsContainers) {
|
||||||
|
out.ErrLn("")
|
||||||
|
out.ErrT(out.Conflict, "Your Docker Desktop container OS type is Windows but Linux is required.")
|
||||||
|
out.T(out.Warning, "Please change Docker settings to use Linux containers instead of Windows containers.")
|
||||||
|
out.T(out.Documentation, "https://minikube.sigs.k8s.io/docs/drivers/docker/#verify-docker-container-type-is-linux")
|
||||||
|
exit.UsageT(`You can verify your Docker container type by running:
|
||||||
|
{{.command}}
|
||||||
|
`, out.V{"command": "docker info --format '{{.OSType}}'"})
|
||||||
|
}
|
||||||
|
|
||||||
|
if errors.Is(err, oci.ErrCPUCountLimit) {
|
||||||
|
out.ErrLn("")
|
||||||
|
out.ErrT(out.Conflict, "{{.name}} doesn't have enough CPUs. ", out.V{"name": viper.GetString("driver")})
|
||||||
|
if runtime.GOOS != "linux" && viper.GetString("driver") == "docker" {
|
||||||
|
out.T(out.Warning, "Please consider changing your Docker Desktop's resources.")
|
||||||
|
out.T(out.Documentation, "https://docs.docker.com/config/containers/resource_constraints/")
|
||||||
|
} else {
|
||||||
|
cpuCount := viper.GetInt(cpus)
|
||||||
|
if cpuCount == 2 {
|
||||||
|
out.T(out.Tip, "Please ensure your system has {{.cpu_counts}} CPU cores.", out.V{"cpu_counts": viper.GetInt(cpus)})
|
||||||
|
} else {
|
||||||
|
out.T(out.Tip, "Please ensure your {{.driver_name}} system has access to {{.cpu_counts}} CPU cores or reduce the number of the specified CPUs", out.V{"driver_name": viper.GetString("driver"), "cpu_counts": viper.GetInt(cpus)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit.UsageT("Ensure your {{.driver_name}} system has enough CPUs. The minimum allowed is 2 CPUs.", out.V{"driver_name": viper.GetString("driver")})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -18,5 +18,11 @@ package oci
|
||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
|
// FailFastError type is an error that could not be solved by trying again
|
||||||
|
type FailFastError error
|
||||||
|
|
||||||
// ErrWindowsContainers is thrown when docker been configured to run windows containers instead of Linux
|
// ErrWindowsContainers is thrown when docker been configured to run windows containers instead of Linux
|
||||||
var ErrWindowsContainers = errors.New("docker container type is windows")
|
var ErrWindowsContainers = FailFastError(errors.New("docker container type is windows"))
|
||||||
|
|
||||||
|
// ErrCPUCountLimit is thrown when docker daemon doesn't have enough CPUs for the requested container
|
||||||
|
var ErrCPUCountLimit = FailFastError(errors.New("not enough CPUs is available for container"))
|
||||||
|
|
|
@ -251,7 +251,11 @@ func createContainer(ociBin string, image string, opts ...createOpt) error {
|
||||||
args = append(args, image)
|
args = append(args, image)
|
||||||
args = append(args, o.ContainerArgs...)
|
args = append(args, o.ContainerArgs...)
|
||||||
|
|
||||||
if _, err := runCmd(exec.Command(ociBin, args...)); err != nil {
|
if rr, err := runCmd(exec.Command(ociBin, args...)); err != nil {
|
||||||
|
// full error: docker: Error response from daemon: Range of CPUs is from 0.01 to 8.00, as there are only 8 CPUs available.
|
||||||
|
if strings.Contains(rr.Output(), "Range of CPUs is from") && strings.Contains(rr.Output(), "CPUs available") { // CPUs available
|
||||||
|
return ErrCPUCountLimit
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,8 +360,7 @@ func startHost(api libmachine.API, cc *config.ClusterConfig, n *config.Node) (*h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't try to re-create if container type is windows.
|
if _, ff := err.(oci.FailFastError); ff {
|
||||||
if errors.Is(err, oci.ErrWindowsContainers) {
|
|
||||||
glog.Infof("will skip retrying to create machine because error is not retriable: %v", err)
|
glog.Infof("will skip retrying to create machine because error is not retriable: %v", err)
|
||||||
return host, exists, err
|
return host, exists, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue