refactor: r replaced github.com/pkg/errors with the standard library errors
parent
f205ef379c
commit
039ac979f1
|
|
@ -18,10 +18,10 @@ package cmd
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/minikube/pkg/minikube/exit"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
|
@ -155,7 +155,7 @@ func GenerateBashCompletion(w io.Writer, cmd *cobra.Command) error {
|
|||
|
||||
err = cmd.GenBashCompletion(w)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error generating bash completion")
|
||||
return fmt.Errorf("Error generating bash completion: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -318,7 +318,7 @@ __minikube_convert_bash_to_zsh() {
|
|||
buf := new(bytes.Buffer)
|
||||
err = cmd.GenBashCompletion(buf)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error generating zsh completion")
|
||||
return fmt.Errorf("Error generating zsh completion: %w", err)
|
||||
}
|
||||
_, err = w.Write(buf.Bytes())
|
||||
if err != nil {
|
||||
|
|
@ -347,7 +347,7 @@ func GenerateFishCompletion(w io.Writer, cmd *cobra.Command) error {
|
|||
|
||||
err = cmd.GenFishCompletion(w, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error generating fish completion")
|
||||
return fmt.Errorf("Error generating fish completion: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -362,7 +362,7 @@ func GeneratePowerShellCompletion(w io.Writer, cmd *cobra.Command) error {
|
|||
|
||||
err = cmd.GenPowerShellCompletionWithDesc(w)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error generating powershell completion")
|
||||
return fmt.Errorf("Error generating powershell completion: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ limitations under the License.
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/exit"
|
||||
|
|
@ -53,28 +54,28 @@ func init() {
|
|||
func Set(name string, value string) error {
|
||||
s, err := findSetting(name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "find settings for %q value of %q", name, value)
|
||||
return fmt.Errorf("find settings for %q value of %q: %w", name, value, err)
|
||||
}
|
||||
// Validate the new value
|
||||
err = invoke(name, value, s.validations)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "run validations for %q with value of %q", name, value)
|
||||
return fmt.Errorf("run validations for %q with value of %q: %w", name, value, err)
|
||||
}
|
||||
|
||||
// Set the value
|
||||
cc, err := config.ReadConfig(localpath.ConfigFile())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "read config file %q", localpath.ConfigFile())
|
||||
return fmt.Errorf("read config file %q: %w", localpath.ConfigFile(), err)
|
||||
}
|
||||
err = s.set(cc, name, value)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "set")
|
||||
return fmt.Errorf("set: %w", err)
|
||||
}
|
||||
|
||||
// Run any callbacks for this property
|
||||
err = invoke(name, value, s.callbacks)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "run callbacks for %q with value of %q", name, value)
|
||||
return fmt.Errorf("run callbacks for %q with value of %q: %w", name, value, err)
|
||||
}
|
||||
|
||||
// Write the value
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package cmd
|
|||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"fmt"
|
||||
|
|
@ -153,13 +152,13 @@ func remoteCommandRunner(co *mustload.ClusterController, nodeName string) comman
|
|||
|
||||
h, err := machine.GetHost(co.API, *co.Config, *n)
|
||||
if err != nil {
|
||||
out.ErrLn("%v", errors.Wrap(err, "getting host"))
|
||||
out.ErrLn("%v", fmt.Errorf("getting host: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
runner, err := machine.CommandRunner(h)
|
||||
if err != nil {
|
||||
out.ErrLn("%v", errors.Wrap(err, "getting command runner"))
|
||||
out.ErrLn("%v", fmt.Errorf("getting command runner: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +171,7 @@ func copyableFile(co *mustload.ClusterController, src, dst *remotePath) assets.C
|
|||
runner := remoteCommandRunner(co, src.node)
|
||||
f, err := runner.ReadableFile(src.path)
|
||||
if err != nil {
|
||||
out.ErrLn("%v", errors.Wrapf(err, "getting file from %s node", src.node))
|
||||
out.ErrLn("%v", fmt.Errorf("getting file from %s node: %w", src.node, err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +192,7 @@ func copyableFile(co *mustload.ClusterController, src, dst *remotePath) assets.C
|
|||
|
||||
fa, err := assets.NewFileAsset(src.path, pt.Dir(dst.path), pt.Base(dst.path), "0644")
|
||||
if err != nil {
|
||||
out.ErrLn("%v", errors.Wrap(err, "getting file asset"))
|
||||
out.ErrLn("%v", fmt.Errorf("getting file asset: %w", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/cmd/minikube/cmd/flags"
|
||||
|
|
@ -148,12 +147,12 @@ func kubectlProxy(kubectlVersion string, binaryURL string, contextName string, p
|
|||
|
||||
stdoutPipe, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, "", errors.Wrap(err, "cmd stdout")
|
||||
return nil, "", fmt.Errorf("cmd stdout: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("Executing: %s %s", cmd.Path, cmd.Args)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, "", errors.Wrap(err, "proxy start")
|
||||
return nil, "", fmt.Errorf("proxy start: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("Waiting for kubectl to output host:port ...")
|
||||
|
|
@ -214,7 +213,7 @@ func dashboardURL(addr string, ns string, svc string) string {
|
|||
func checkURL(url string) error {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "hitting URL:%q\n response: %+v", url, resp)
|
||||
return fmt.Errorf("hitting URL:%q\n response: %+v: %w", url, resp, err)
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return &retry.RetriableError{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/process"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnerror"
|
||||
|
||||
|
|
@ -435,10 +436,10 @@ func deleteHosts(api libmachine.API, cc *config.ClusterConfig) {
|
|||
for _, n := range cc.Nodes {
|
||||
machineName := config.MachineName(*cc, n)
|
||||
if err := machine.DeleteHost(api, machineName); err != nil {
|
||||
switch errors.Cause(err).(type) {
|
||||
case mcnerror.ErrHostDoesNotExist:
|
||||
var e mcnerror.ErrHostDoesNotExist
|
||||
if errors.As(err, &e) {
|
||||
klog.Infof("Host %s does not exist. Proceeding ahead with cleanup.", machineName)
|
||||
default:
|
||||
} else {
|
||||
out.FailureT("Failed to delete cluster: {{.error}}", out.V{"error": err})
|
||||
out.Styled(style.Notice, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": machineName})
|
||||
}
|
||||
|
|
@ -653,7 +654,7 @@ func killProcess(path string) error {
|
|||
|
||||
// if no errors were encountered, it's safe to delete pidFile
|
||||
if err := os.Remove(pidPath); err != nil {
|
||||
return errors.Wrap(err, "while closing mount-pids file")
|
||||
return fmt.Errorf("while closing mount-pids file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -674,13 +675,13 @@ func trySigKillProcess(pid int) error {
|
|||
|
||||
proc, err := os.FindProcess(pid)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "os.FindProcess: %d", pid)
|
||||
return fmt.Errorf("os.FindProcess: %d: %w", pid, err)
|
||||
}
|
||||
|
||||
klog.Infof("Killing pid %d ...", pid)
|
||||
if err := proc.Kill(); err != nil {
|
||||
klog.Infof("Kill failed with %v - removing probably stale pid...", err)
|
||||
return errors.Wrapf(err, "removing likely stale unkillable pid: %d", pid)
|
||||
return fmt.Errorf("removing likely stale unkillable pid: %d: %w", pid, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -717,7 +718,7 @@ var isMinikubeProcess = func(pid int) (bool, error) {
|
|||
func getPids(path string) ([]int, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ReadFile")
|
||||
return nil, fmt.Errorf("ReadFile: %w", err)
|
||||
}
|
||||
klog.Infof("pidfile contents: %s", data)
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/cmd/minikube/cmd/flags"
|
||||
|
|
@ -281,7 +280,7 @@ func getPort() (int, error) {
|
|||
|
||||
l, err := net.ListenTCP("tcp", addr)
|
||||
if err != nil {
|
||||
return -1, errors.Errorf("Error accessing port %d", addr.Port)
|
||||
return -1, fmt.Errorf("Error accessing port %d", addr.Port)
|
||||
}
|
||||
defer l.Close()
|
||||
return l.Addr().(*net.TCPAddr).Port, nil
|
||||
|
|
@ -318,7 +317,7 @@ func removePid(path string, pid string) error {
|
|||
// we're reading the pids...
|
||||
data, err := os.ReadFile(pidPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "readFile")
|
||||
return fmt.Errorf("readFile: %w", err)
|
||||
}
|
||||
|
||||
pids := []string{}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,14 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/Delta456/box-cli-maker/v2"
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/google/go-containerregistry/pkg/authn"
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
gopshost "github.com/shirou/gopsutil/v4/host"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -348,7 +349,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
|
|||
rtime := getContainerRuntime(existing)
|
||||
cc, n, err := generateClusterConfig(cmd, existing, k8sVersion, rtime, driverName, options)
|
||||
if err != nil {
|
||||
return node.Starter{}, errors.Wrap(err, "Failed to generate cluster config")
|
||||
return node.Starter{}, fmt.Errorf("Failed to generate cluster config: %w", err)
|
||||
}
|
||||
klog.Infof("cluster config:\n%+v", cc)
|
||||
|
||||
|
|
@ -371,7 +372,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
|
|||
if driver.IsVM(driverName) && !driver.IsSSH(driverName) {
|
||||
urlString, err := download.ISO(viper.GetStringSlice(isoURL), cmd.Flags().Changed(isoURL))
|
||||
if err != nil {
|
||||
return node.Starter{}, errors.Wrap(err, "Failed to cache ISO")
|
||||
return node.Starter{}, fmt.Errorf("Failed to cache ISO: %w", err)
|
||||
}
|
||||
cc.MinikubeISO = urlString
|
||||
}
|
||||
|
|
@ -521,7 +522,7 @@ func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config.
|
|||
|
||||
out.Ln("") // extra newline for clarity on the command line
|
||||
if err := node.Add(starter.Cfg, n, viper.GetBool(deleteOnFailure), options); err != nil {
|
||||
return nil, errors.Wrap(err, "adding node")
|
||||
return nil, fmt.Errorf("adding node: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -617,7 +618,7 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion, rtime, machineName st
|
|||
|
||||
client, err := semver.Make(strings.TrimPrefix(gitVersion, version.VersionPrefix))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "client semver")
|
||||
return fmt.Errorf("client semver: %w", err)
|
||||
}
|
||||
|
||||
cluster := semver.MustParse(strings.TrimPrefix(k8sVersion, version.VersionPrefix))
|
||||
|
|
@ -688,7 +689,7 @@ func kubectlVersion(path string) (string, error) {
|
|||
// really old Kubernetes clients did not have the --output parameter
|
||||
b, err := exec.Command(path, "version", "--client", "--short").Output()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "exec")
|
||||
return "", fmt.Errorf("exec: %w", err)
|
||||
}
|
||||
s := strings.TrimSpace(string(b))
|
||||
return strings.Replace(s, "Client Version: ", "", 1), nil
|
||||
|
|
@ -701,7 +702,7 @@ func kubectlVersion(path string) (string, error) {
|
|||
}{}
|
||||
err = json.Unmarshal(j, &cv)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "unmarshal")
|
||||
return "", fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
|
||||
return cv.ClientVersion.GitVersion, nil
|
||||
|
|
@ -1406,7 +1407,7 @@ func validatePorts(ports []string) error {
|
|||
}
|
||||
_, portBindingsMap, err := nat.ParsePortSpecs(portSpecs)
|
||||
if err != nil {
|
||||
return errors.Errorf("Sorry, one of the ports provided with --ports flag is not valid %s (%v)", ports, err)
|
||||
return fmt.Errorf("Sorry, one of the ports provided with --ports flag is not valid %s (%v)", ports, err)
|
||||
}
|
||||
for exposedPort, portBindings := range portBindingsMap {
|
||||
exposedPorts = append(exposedPorts, exposedPort.Port())
|
||||
|
|
@ -1430,10 +1431,10 @@ func validatePorts(ports []string) error {
|
|||
func validatePort(port string) error {
|
||||
p, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
return errors.Errorf("Sorry, one of the ports provided with --ports flag is not valid: %s", port)
|
||||
return fmt.Errorf("Sorry, one of the ports provided with --ports flag is not valid: %s", port)
|
||||
}
|
||||
if p > 65535 || p < 1 {
|
||||
return errors.Errorf("Sorry, one of the ports provided with --ports flag is outside range: %s", port)
|
||||
return fmt.Errorf("Sorry, one of the ports provided with --ports flag is outside range: %s", port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1442,10 +1443,10 @@ func validatePort(port string) error {
|
|||
func validateDiskSize(diskSize string) error {
|
||||
diskSizeMB, err := util.CalculateSizeInMB(diskSize)
|
||||
if err != nil {
|
||||
return errors.Errorf("Validation unable to parse disk size %v: %v", diskSize, err)
|
||||
return fmt.Errorf("Validation unable to parse disk size %v: %v", diskSize, err)
|
||||
}
|
||||
if diskSizeMB < minimumDiskSize {
|
||||
return errors.Errorf("Requested disk size %v is less than minimum of %v", diskSizeMB, minimumDiskSize)
|
||||
return fmt.Errorf("Requested disk size %v is less than minimum of %v", diskSizeMB, minimumDiskSize)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1474,11 +1475,11 @@ func validateRuntime(rtime string) error {
|
|||
}
|
||||
|
||||
if (rtime == "crio" || rtime == "cri-o") && strings.HasPrefix(runtime.GOARCH, "ppc64") {
|
||||
return errors.Errorf("The %s runtime is not compatible with the %s architecture. See https://github.com/cri-o/cri-o/issues/2467 for more details", rtime, runtime.GOARCH)
|
||||
return fmt.Errorf("The %s runtime is not compatible with the %s architecture. See https://github.com/cri-o/cri-o/issues/2467 for more details", rtime, runtime.GOARCH)
|
||||
}
|
||||
|
||||
if !validRuntime {
|
||||
return errors.Errorf("Invalid Container Runtime: %s. Valid runtimes are: %s", rtime, cruntime.ValidRuntimes())
|
||||
return fmt.Errorf("Invalid Container Runtime: %s. Valid runtimes are: %s", rtime, cruntime.ValidRuntimes())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1492,12 +1493,12 @@ func validateGPUs(value, drvName, rtime string) error {
|
|||
return err
|
||||
}
|
||||
if value != "nvidia" && value != "all" && value != "amd" && value != "nvidia.com" {
|
||||
return errors.Errorf(`The gpus flag must be passed a value of "nvidia", "nvidia.com", "amd" or "all"`)
|
||||
return fmt.Errorf(`The gpus flag must be passed a value of "nvidia", "nvidia.com", "amd" or "all"`)
|
||||
}
|
||||
if drvName == constants.Docker && (rtime == constants.Docker || rtime == constants.DefaultContainerRuntime) {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("The gpus flag can only be used with the docker driver and docker container-runtime")
|
||||
return fmt.Errorf("The gpus flag can only be used with the docker driver and docker container-runtime")
|
||||
}
|
||||
|
||||
func validateGPUsArch() error {
|
||||
|
|
@ -1505,7 +1506,7 @@ func validateGPUsArch() error {
|
|||
case "amd64", "arm64", "ppc64le":
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("The GPUs flag is only supported on amd64, arm64 & ppc64le, currently using %s", runtime.GOARCH)
|
||||
return fmt.Errorf("The GPUs flag is only supported on amd64, arm64 & ppc64le, currently using %s", runtime.GOARCH)
|
||||
}
|
||||
|
||||
func validateAutoPauseInterval(interval time.Duration) error {
|
||||
|
|
@ -1710,7 +1711,7 @@ func validateInsecureRegistry() {
|
|||
func configureNodes(cc config.ClusterConfig, existing *config.ClusterConfig) (config.ClusterConfig, config.Node, error) {
|
||||
kv, err := getKubernetesVersion(&cc)
|
||||
if err != nil {
|
||||
return cc, config.Node{}, errors.Wrapf(err, "failed getting kubernetes version")
|
||||
return cc, config.Node{}, fmt.Errorf("failed getting kubernetes version: %w", err)
|
||||
}
|
||||
cr := getContainerRuntime(&cc)
|
||||
|
||||
|
|
@ -1739,7 +1740,7 @@ func configureNodes(cc config.ClusterConfig, existing *config.ClusterConfig) (co
|
|||
|
||||
pcp, err := config.ControlPlane(*existing)
|
||||
if err != nil {
|
||||
return cc, config.Node{}, errors.Wrapf(err, "failed getting control-plane node")
|
||||
return cc, config.Node{}, fmt.Errorf("failed getting control-plane node: %w", err)
|
||||
}
|
||||
pcp.KubernetesVersion = kv
|
||||
pcp.ContainerRuntime = cr
|
||||
|
|
@ -1760,7 +1761,7 @@ func autoSetDriverOptions(cmd *cobra.Command, drvName string) (err error) {
|
|||
klog.Infof("auto setting extra-config to %q.", eo)
|
||||
err = config.ExtraOptions.Set(eo)
|
||||
if err != nil {
|
||||
err = errors.Wrapf(err, "setting extra option %s", eo)
|
||||
err = fmt.Errorf("setting extra option %s: %w", eo, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1964,16 +1965,16 @@ func validateDockerStorageDriver(drvName string) {
|
|||
func validateSubnet(subnet string) error {
|
||||
ip, cidr, err := netutil.ParseAddr(subnet)
|
||||
if err != nil {
|
||||
return errors.Errorf("Sorry, unable to parse subnet: %v", err)
|
||||
return fmt.Errorf("Sorry, unable to parse subnet: %v", err)
|
||||
}
|
||||
if !ip.IsPrivate() {
|
||||
return errors.Errorf("Sorry, the subnet %s is not a private IP", ip)
|
||||
return fmt.Errorf("Sorry, the subnet %s is not a private IP", ip)
|
||||
}
|
||||
|
||||
if cidr != nil {
|
||||
mask, _ := cidr.Mask.Size()
|
||||
if mask > 30 {
|
||||
return errors.Errorf("Sorry, the subnet provided does not have a mask less than or equal to /30")
|
||||
return fmt.Errorf("Sorry, the subnet provided does not have a mask less than or equal to /30")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -2049,10 +2050,10 @@ func exitIfNotForced(r reason.Kind, message string, v ...out.V) {
|
|||
}
|
||||
|
||||
func exitGuestProvision(err error) {
|
||||
if errors.Cause(err) == oci.ErrInsufficientDockerStorage {
|
||||
if errors.Is(err, oci.ErrInsufficientDockerStorage) {
|
||||
exit.Message(reason.RsrcInsufficientDockerStorage, "preload extraction failed: \"No space left on device\"")
|
||||
}
|
||||
if errors.Cause(err) == oci.ErrGetSSHPortContainerNotRunning {
|
||||
if errors.Is(err, oci.ErrGetSSHPortContainerNotRunning) {
|
||||
exit.Message(reason.GuestProvisionContainerExited, "Docker container exited prematurely after it was created, consider investigating Docker's performance/health.")
|
||||
}
|
||||
exit.Error(reason.GuestProvision, "error provisioning guest", err)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
|
@ -327,7 +326,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
|||
|
||||
// identify appropriate cni then configure cruntime accordingly
|
||||
if _, err := cni.New(&cc); err != nil {
|
||||
return cc, config.Node{}, errors.Wrap(err, "cni")
|
||||
return cc, config.Node{}, fmt.Errorf("cni: %w", err)
|
||||
}
|
||||
} else {
|
||||
klog.Info("no existing cluster config was found, will generate one from the flags ")
|
||||
|
|
@ -335,7 +334,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
|||
|
||||
cnm, err := cni.New(&cc)
|
||||
if err != nil {
|
||||
return cc, config.Node{}, errors.Wrap(err, "cni")
|
||||
return cc, config.Node{}, fmt.Errorf("cni: %w", err)
|
||||
}
|
||||
|
||||
if _, ok := cnm.(cni.Disabled); !ok {
|
||||
|
|
@ -346,7 +345,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
|||
|
||||
r, err := cruntime.New(cruntime.Config{Type: cc.KubernetesConfig.ContainerRuntime})
|
||||
if err != nil {
|
||||
return cc, config.Node{}, errors.Wrap(err, "new runtime manager")
|
||||
return cc, config.Node{}, fmt.Errorf("new runtime manager: %w", err)
|
||||
}
|
||||
|
||||
// Feed Docker our host proxy environment by default, so that it can pull images
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/cmd/minikube/cmd/flags"
|
||||
|
|
@ -227,7 +226,7 @@ func clusterStatusJSON(statuses []*cluster.Status, w io.Writer, cc *config.Clust
|
|||
|
||||
bs, err := json.Marshal(cs)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshal")
|
||||
return fmt.Errorf("marshal: %w", err)
|
||||
}
|
||||
|
||||
_, err = w.Write(bs)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ import (
|
|||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/klog/v2"
|
||||
|
|
@ -167,14 +168,15 @@ func stop(api libmachine.API, machineName string) bool {
|
|||
}
|
||||
klog.Warningf("stop host returned error: %v", err)
|
||||
|
||||
switch err := errors.Cause(err).(type) {
|
||||
case mcnerror.ErrHostDoesNotExist:
|
||||
klog.Warningf("stop host returned error: %v", err)
|
||||
|
||||
var e mcnerror.ErrHostDoesNotExist
|
||||
if errors.As(err, &e) {
|
||||
out.Styled(style.Meh, `"{{.machineName}}" does not exist, nothing to stop`, out.V{"machineName": machineName})
|
||||
nonexistent = true
|
||||
return nil
|
||||
default:
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := retry.Expo(tryStop, 1*time.Second, 120*time.Second, 5); err != nil {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/perf/monitor"
|
||||
)
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ func analyzePerformance(ctx context.Context) error {
|
|||
client := monitor.NewClient(ctx, monitor.GithubOwner, monitor.GithubRepo)
|
||||
prs, err := client.ListOpenPRsWithLabel(monitor.OkToTestLabel)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "listing open prs")
|
||||
return fmt.Errorf("listing open prs: %w", err)
|
||||
}
|
||||
log.Print("got prs:", prs)
|
||||
for _, pr := range prs {
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -48,7 +48,6 @@ require (
|
|||
github.com/otiai10/copy v1.14.1
|
||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/profile v1.7.0
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
|
||||
github.com/shirou/gopsutil/v4 v4.25.12
|
||||
|
|
@ -199,6 +198,7 @@ require (
|
|||
github.com/otiai10/mint v1.6.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.17 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/xattr v0.4.9 // indirect
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
"gonum.org/v1/plot"
|
||||
"gonum.org/v1/plot/plotter"
|
||||
"gonum.org/v1/plot/plotutil"
|
||||
|
|
@ -77,7 +77,7 @@ func execute() error {
|
|||
napFn := "./out/benchmark-results/" + sessionID + "/cstat.nonautopause.summary"
|
||||
napFile, err := os.Open(napFn)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Missing summary csv")
|
||||
return fmt.Errorf("Missing summary csv: %w", err)
|
||||
}
|
||||
defer napFile.Close()
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ func execute() error {
|
|||
|
||||
s, err := strconv.ParseFloat(napLine[0], 64)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to convert to float64")
|
||||
return fmt.Errorf("Failed to convert to float64: %w", err)
|
||||
}
|
||||
napResults = append(napResults, s)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ func execute() error {
|
|||
apFn := "./out/benchmark-results/" + sessionID + "/cstat.autopause.summary"
|
||||
apFile, err := os.Open(apFn)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Missing summary csv")
|
||||
return fmt.Errorf("Missing summary csv: %w", err)
|
||||
}
|
||||
defer apFile.Close()
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ func execute() error {
|
|||
|
||||
s, err := strconv.ParseFloat(apLine[0], 64)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to convert to float64")
|
||||
return fmt.Errorf("Failed to convert to float64: %w", err)
|
||||
}
|
||||
apResults = append(apResults, s)
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ func execute() error {
|
|||
// Create Bar instance with non-autopause benchmark results
|
||||
barNAP, err := plotter.NewBarChart(plotter.Values(napResults), breadth)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar chart")
|
||||
return fmt.Errorf("Failed to create bar chart: %w", err)
|
||||
}
|
||||
|
||||
// Set border of the bar graph. 0 is no border color
|
||||
|
|
@ -141,7 +141,7 @@ func execute() error {
|
|||
// Create Bar instance with auto-pause benchmark results
|
||||
barAP, err := plotter.NewBarChart(plotter.Values(apResults), breadth)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar chart")
|
||||
return fmt.Errorf("Failed to create bar chart: %w", err)
|
||||
}
|
||||
|
||||
// Set border of the bar graph. 0 is no border color
|
||||
|
|
@ -229,12 +229,12 @@ func execute() error {
|
|||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
if err := p.Save(13*vg.Inch, 8*vg.Inch, FOLDER+"/mac.png"); err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar graph png")
|
||||
return fmt.Errorf("Failed to create bar graph png: %w", err)
|
||||
}
|
||||
log.Printf("Generated graph png to %s/mac.png", FOLDER)
|
||||
case "linux":
|
||||
if err := p.Save(13*vg.Inch, 10*vg.Inch, FOLDER+"/linux.png"); err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar graph png")
|
||||
return fmt.Errorf("Failed to create bar graph png: %w", err)
|
||||
}
|
||||
log.Printf("Generated graph png to %s/linux.png", FOLDER)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
"gonum.org/v1/plot"
|
||||
"gonum.org/v1/plot/plotter"
|
||||
"gonum.org/v1/plot/plotutil"
|
||||
|
|
@ -76,7 +76,7 @@ func execute() error {
|
|||
fn := "./out/benchmark-results/" + sessionID + "/cstat.summary"
|
||||
file, err := os.Open(fn)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Missing summary csv")
|
||||
return fmt.Errorf("Missing summary csv: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ func execute() error {
|
|||
|
||||
s, err := strconv.ParseFloat(line[0], 64)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to convert to float64")
|
||||
return fmt.Errorf("Failed to convert to float64: %w", err)
|
||||
}
|
||||
results = append(results, s)
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ func execute() error {
|
|||
// Create Bar instance with benchmark results
|
||||
bar, err := plotter.NewBarChart(plotter.Values(results), breadth)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar chart")
|
||||
return fmt.Errorf("Failed to create bar chart: %w", err)
|
||||
}
|
||||
|
||||
// Set border of the bar graph. 0 is no border color
|
||||
|
|
@ -157,12 +157,12 @@ func execute() error {
|
|||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
if err := p.Save(13*vg.Inch, 8*vg.Inch, FOLDER+"/mac.png"); err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar graph png")
|
||||
return fmt.Errorf("Failed to create bar graph png: %w", err)
|
||||
}
|
||||
log.Printf("Generated graph png to %s/mac.png", FOLDER)
|
||||
case "linux":
|
||||
if err := p.Save(13*vg.Inch, 10*vg.Inch, FOLDER+"/linux.png"); err != nil {
|
||||
return errors.Wrap(err, "Failed to create bar graph png")
|
||||
return fmt.Errorf("Failed to create bar graph png: %w", err)
|
||||
}
|
||||
log.Printf("Generated graph png to %s/linux.png", FOLDER)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import (
|
|||
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -93,7 +93,7 @@ var (
|
|||
var out bytes.Buffer
|
||||
cmd.Stderr = &out
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Errorf("%s: %s", err.Error(), out.String())
|
||||
return fmt.Errorf("%s: %s", err.Error(), out.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ func prepareImage(ctx context.Context, current, release string) (image string, e
|
|||
}
|
||||
}
|
||||
if image == "" {
|
||||
return "", errors.Errorf("cannot find current image version tag %s locally nor in any registry", current)
|
||||
return "", fmt.Errorf("cannot find current image version tag %s locally nor in any registry", current)
|
||||
}
|
||||
// tag current image with release version
|
||||
tag := exec.CommandContext(ctx, "docker", "tag", image+":"+current, image+":"+release)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import (
|
|||
"time"
|
||||
|
||||
_ "cloud.google.com/go/storage"
|
||||
"errors"
|
||||
mexporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric"
|
||||
"github.com/pkg/errors"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
|
||||
|
|
@ -65,7 +65,7 @@ func execute() error {
|
|||
}
|
||||
ctx := context.Background()
|
||||
if err := downloadMinikube(ctx, tmpFile); err != nil {
|
||||
return errors.Wrap(err, "downloading minikube")
|
||||
return fmt.Errorf("downloading minikube: %w", err)
|
||||
}
|
||||
|
||||
for _, cr := range []string{"docker", "containerd", "crio"} {
|
||||
|
|
@ -79,19 +79,19 @@ func execute() error {
|
|||
func exportMinikubeStart(ctx context.Context, projectID, containerRuntime string) error {
|
||||
mp, attrs, err := getMeterProvider(projectID, containerRuntime)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating meter provider")
|
||||
return fmt.Errorf("creating meter provider: %w", err)
|
||||
}
|
||||
defer func() { _ = mp.Shutdown(ctx) }()
|
||||
|
||||
meter := mp.Meter("minikube")
|
||||
latency, err := meter.Float64Histogram(customMetricName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating histogram")
|
||||
return fmt.Errorf("creating histogram: %w", err)
|
||||
}
|
||||
|
||||
st, err := minikubeStartTime(ctx, projectID, tmpFile, containerRuntime)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "collecting start time")
|
||||
return fmt.Errorf("collecting start time: %w", err)
|
||||
}
|
||||
fmt.Printf("Latency: %f\n", st)
|
||||
latency.Record(ctx, st, metric.WithAttributes(attrs...))
|
||||
|
|
@ -137,7 +137,7 @@ func minikubeStartTime(ctx context.Context, projectID, minikubePath, containerRu
|
|||
t := time.Now()
|
||||
log.Printf("Running [%v]....", cmd.Args)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return 0, errors.Wrapf(err, "running %v", cmd.Args)
|
||||
return 0, fmt.Errorf("running %v: %w", cmd.Args, err)
|
||||
}
|
||||
totalTime := time.Since(t).Seconds()
|
||||
return totalTime, nil
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"log"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -39,7 +39,7 @@ const (
|
|||
func downloadMinikube(ctx context.Context, minikubePath string) error {
|
||||
client, err := storage.NewClient(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating client")
|
||||
return fmt.Errorf("creating client: %w", err)
|
||||
}
|
||||
obj := client.Bucket("minikube").Object(fmt.Sprintf("latest/%s", binary()))
|
||||
|
||||
|
|
@ -52,20 +52,20 @@ func downloadMinikube(ctx context.Context, minikubePath string) error {
|
|||
// download minikube binary from GCS
|
||||
rc, err := obj.NewReader(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "gcs new reader")
|
||||
return fmt.Errorf("gcs new reader: %w", err)
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
data, err := io.ReadAll(rc)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "io read all")
|
||||
return fmt.Errorf("io read all: %w", err)
|
||||
}
|
||||
log.Printf("downloading gs://%s/%s to %v", bucketName, binary(), minikubePath)
|
||||
if err := os.WriteFile(minikubePath, data, 0777); err != nil {
|
||||
return errors.Wrap(err, "writing minikubePath")
|
||||
return fmt.Errorf("writing minikubePath: %w", err)
|
||||
}
|
||||
if err := os.Chmod(minikubePath, 0700); err != nil {
|
||||
return errors.Wrap(err, "chmod")
|
||||
return fmt.Errorf("chmod: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
"k8s.io/minikube/pkg/drivers/kic"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil"
|
||||
|
|
@ -56,16 +56,16 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
defer os.Remove(baseDir)
|
||||
|
||||
if err := os.MkdirAll(baseDir, 0755); err != nil {
|
||||
return errors.Wrap(err, "mkdir")
|
||||
return fmt.Errorf("mkdir: %w", err)
|
||||
}
|
||||
if err := driver.Create(); err != nil {
|
||||
return errors.Wrap(err, "creating kic driver")
|
||||
return fmt.Errorf("creating kic driver: %w", err)
|
||||
}
|
||||
|
||||
// Now, get images to pull
|
||||
imgs, err := images.Kubeadm("", kubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "kubeadm images")
|
||||
return fmt.Errorf("kubeadm images: %w", err)
|
||||
}
|
||||
|
||||
if containerRuntime != "docker" { // kic overlay image is only needed by containerd and cri-o https://github.com/kubernetes/minikube/issues/7428
|
||||
|
|
@ -77,7 +77,7 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
// will need to do this to enable the container run-time service
|
||||
sv, err := util.ParseKubernetesVersion(kubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to parse Kubernetes version")
|
||||
return fmt.Errorf("Failed to parse Kubernetes version: %w", err)
|
||||
}
|
||||
|
||||
co := cruntime.Config{
|
||||
|
|
@ -88,16 +88,16 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
}
|
||||
cr, err := cruntime.New(co)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed create new runtime")
|
||||
return fmt.Errorf("failed create new runtime: %w", err)
|
||||
}
|
||||
|
||||
if err := cr.Enable(true, detect.CgroupDriver(), false); err != nil {
|
||||
return errors.Wrap(err, "enable container runtime")
|
||||
return fmt.Errorf("enable container runtime: %w", err)
|
||||
}
|
||||
|
||||
// Verify storage driver/snapshotter after the runtime has been configured.
|
||||
if err := verifyStorage(containerRuntime); err != nil {
|
||||
return errors.Wrap(err, "verifying storage")
|
||||
return fmt.Errorf("verifying storage: %w", err)
|
||||
}
|
||||
|
||||
for _, img := range imgs {
|
||||
|
|
@ -107,13 +107,13 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
time.Sleep(time.Second) // to avoid error: : exec: already started
|
||||
return errors.Wrapf(err, "pulling image %s", img)
|
||||
return fmt.Errorf("pulling image %s: %w", img, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// retry up to 5 times if network is bad
|
||||
if err = retry.Expo(pull, time.Microsecond, time.Minute, 5); err != nil {
|
||||
return errors.Wrapf(err, "pull image %s", img)
|
||||
return fmt.Errorf("pull image %s: %w", img, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -126,11 +126,11 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
sm := sysinit.New(runner)
|
||||
|
||||
if err := bsutil.TransferBinaries(kcfg, runner, sm, ""); err != nil {
|
||||
return errors.Wrap(err, "transferring k8s binaries")
|
||||
return fmt.Errorf("transferring k8s binaries: %w", err)
|
||||
}
|
||||
// Create image tarball
|
||||
if err := createImageTarball(tarballFilename, containerRuntime); err != nil {
|
||||
return errors.Wrap(err, "create tarball")
|
||||
return fmt.Errorf("create tarball: %w", err)
|
||||
}
|
||||
|
||||
return copyTarballToHost(tarballFilename)
|
||||
|
|
@ -139,17 +139,17 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
|
|||
func verifyStorage(containerRuntime string) error {
|
||||
if containerRuntime == "docker" {
|
||||
if err := retry.Expo(verifyDockerStorage, 100*time.Microsecond, time.Minute*2); err != nil {
|
||||
return errors.Wrap(err, "Docker storage type is incompatible")
|
||||
return fmt.Errorf("Docker storage type is incompatible: %w", err)
|
||||
}
|
||||
}
|
||||
if containerRuntime == "containerd" {
|
||||
if err := retry.Expo(verifyContainerdStorage, 100*time.Microsecond, time.Minute*2); err != nil {
|
||||
return errors.Wrap(err, "containerd storage type is incompatible")
|
||||
return fmt.Errorf("containerd storage type is incompatible: %w", err)
|
||||
}
|
||||
}
|
||||
if containerRuntime == "cri-o" {
|
||||
if err := retry.Expo(verifyPodmanStorage, 100*time.Microsecond, time.Minute*2); err != nil {
|
||||
return errors.Wrap(err, "Podman storage type is incompatible")
|
||||
return fmt.Errorf("Podman storage type is incompatible: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -194,7 +194,7 @@ func createImageTarball(tarballFilename, containerRuntime string) error {
|
|||
cmd := exec.Command("docker", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrapf(err, "tarball cmd: %s", cmd.Args)
|
||||
return fmt.Errorf("tarball cmd: %s: %w", cmd.Args, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ func copyTarballToHost(tarballFilename string) error {
|
|||
cmd := exec.Command("docker", "cp", fmt.Sprintf("%s:/%s", profile, tarballFilename), dest)
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrapf(err, "cp cmd: %s", cmd.Args)
|
||||
return fmt.Errorf("cp cmd: %s: %w", cmd.Args, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
|
|
@ -152,7 +152,7 @@ func makePreload(cfg preloadCfg) error {
|
|||
}()
|
||||
|
||||
if err := generateTarball(kv, cr, tf); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("generating tarball for k8s version %s with %s", kv, cr))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("generating tarball for k8s version %s with %s", kv, cr), err)
|
||||
}
|
||||
|
||||
if *noUpload {
|
||||
|
|
@ -160,7 +160,7 @@ func makePreload(cfg preloadCfg) error {
|
|||
return nil
|
||||
}
|
||||
if err := uploadTarballToGCS(tf, kv); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("uploading tarball for k8s version %s with %s", kv, cr))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("uploading tarball for k8s version %s with %s", kv, cr), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
"k8s.io/minikube/pkg/minikube/download"
|
||||
)
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ func uploadTarball(tarballFilename, k8sVer string) error {
|
|||
cmd := exec.Command("gsutil", "cp", hostPath, gcsDest)
|
||||
fmt.Printf("Running: %v\n", cmd.Args)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "uploading %s to GCS bucket: %v\n%s", hostPath, err, string(output))
|
||||
return fmt.Errorf("uploading %s to GCS bucket: %v\n%s: %w", hostPath, err, string(output), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ func uploadArmTarballs(preloadsDir string) error {
|
|||
cmd := exec.Command("gsutil", "cp", hostPath, gcsDest)
|
||||
fmt.Printf("Running: %v\n", cmd.Args)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "uploading %s to GCS bucket: %v\n%s", hostPath, err, string(output))
|
||||
return fmt.Errorf("uploading %s to GCS bucket: %v\n%s: %w", hostPath, err, string(output), err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
filesProcessed := 0
|
||||
filesModified := 0
|
||||
skippedCalls := 0
|
||||
|
||||
err := filepath.Walk(".", func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !strings.HasSuffix(path, ".go") {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(path, "vendor/") {
|
||||
return nil
|
||||
}
|
||||
if info.IsDir() {
|
||||
if info.Name() == "vendor" || info.Name() == ".git" {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Skip self
|
||||
if strings.Contains(path, "rewrite_pkg_errors.go") {
|
||||
return nil
|
||||
}
|
||||
|
||||
fset := token.NewFileSet()
|
||||
node, err := parser.ParseFile(fset, path, nil, parser.ParseComments)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
usesPkgErrors := false
|
||||
for _, imp := range node.Imports {
|
||||
if imp.Path.Value == "\"github.com/pkg/errors\"" {
|
||||
usesPkgErrors = true
|
||||
imp.Path.Value = "\"errors\""
|
||||
}
|
||||
}
|
||||
|
||||
if !usesPkgErrors {
|
||||
return nil
|
||||
}
|
||||
filesProcessed++
|
||||
|
||||
rewritten := false
|
||||
|
||||
ast.Inspect(node, func(n ast.Node) bool {
|
||||
call, ok := n.(*ast.CallExpr)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
sel, ok := call.Fun.(*ast.SelectorExpr)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
ident, ok := sel.X.(*ast.Ident)
|
||||
if !ok || ident.Name != "errors" {
|
||||
return true
|
||||
}
|
||||
|
||||
if sel.Sel.Name == "Wrap" || sel.Sel.Name == "Wrapf" {
|
||||
if len(call.Args) < 2 {
|
||||
return true
|
||||
}
|
||||
errArg := call.Args[0]
|
||||
|
||||
// Safety Check: If errArg is a function call, replacing with fmt.Errorf is UNSAFE
|
||||
if _, isCall := errArg.(*ast.CallExpr); isCall {
|
||||
fmt.Printf("WARNING: Skipping unsafe errors.%s rewrite in %s line %d: error arg is a function call\n",
|
||||
sel.Sel.Name, path, fset.Position(call.Pos()).Line)
|
||||
skippedCalls++
|
||||
// Reset import (partial fix might leave file broken if we don't fix this call)
|
||||
// But we already changed the import in the loop above.
|
||||
// We will manually fix these.
|
||||
return true
|
||||
}
|
||||
|
||||
// errors.Wrap(err, "msg") -> fmt.Errorf("msg: %w", err)
|
||||
msgIndex := 1
|
||||
restArgs := call.Args[2:]
|
||||
|
||||
ident.Name = "fmt"
|
||||
sel.Sel.Name = "Errorf"
|
||||
|
||||
msgArg := call.Args[msgIndex]
|
||||
|
||||
if lit, ok := msgArg.(*ast.BasicLit); ok && lit.Kind == token.STRING {
|
||||
val := lit.Value
|
||||
if len(val) >= 2 {
|
||||
inner := val[1 : len(val)-1]
|
||||
newVal := fmt.Sprintf("\"%s: %%w\"", inner)
|
||||
lit.Value = newVal
|
||||
|
||||
newArgs := []ast.Expr{lit}
|
||||
newArgs = append(newArgs, restArgs...)
|
||||
newArgs = append(newArgs, errArg)
|
||||
call.Args = newArgs
|
||||
rewritten = true
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if len(restArgs) == 0 {
|
||||
fmtStr := &ast.BasicLit{Kind: token.STRING, Value: "\"%s: %w\""}
|
||||
call.Args = []ast.Expr{fmtStr, msgArg, errArg}
|
||||
rewritten = true
|
||||
} else {
|
||||
fmt.Printf("WARNING: Skipped complex errors.Wrapf in %s line %d\n", path, fset.Position(call.Pos()).Line)
|
||||
skippedCalls++
|
||||
ident.Name = "errors"
|
||||
sel.Sel.Name = "Wrapf"
|
||||
}
|
||||
} else if sel.Sel.Name == "Errorf" {
|
||||
ident.Name = "fmt"
|
||||
rewritten = true
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
if rewritten || usesPkgErrors {
|
||||
// Even if we didn't rewrite any calls (e.g. only errors.New or skipped calls),
|
||||
// we changed the import path to "errors".
|
||||
// If we skipped calls, the file will fail to compile (errors.Wrap not defined).
|
||||
// This is desired so we find them.
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := format.Node(f, fset, node); err != nil {
|
||||
f.Close()
|
||||
return err
|
||||
}
|
||||
f.Close()
|
||||
filesModified++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Processed %d files, modified %d files, skipped %d calls\n", filesProcessed, filesModified, skippedCalls)
|
||||
}
|
||||
|
|
@ -28,8 +28,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/libmachine/state"
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ func RunCallbacks(cc *config.ClusterConfig, name string, value string, options *
|
|||
klog.Infof("Setting %s=%s in profile %q", name, value, cc.Name)
|
||||
a, valid := isAddonValid(name)
|
||||
if !valid {
|
||||
return errors.Errorf("%s is not a valid addon", name)
|
||||
return fmt.Errorf("%s is not a valid addon", name)
|
||||
}
|
||||
|
||||
// Run any additional validations for this property
|
||||
|
|
@ -78,7 +79,7 @@ func RunCallbacks(cc *config.ClusterConfig, name string, value string, options *
|
|||
if errors.Is(err, ErrSkipThisAddon) {
|
||||
return err
|
||||
}
|
||||
return errors.Wrap(err, "running validations")
|
||||
return fmt.Errorf("running validations: %w", err)
|
||||
}
|
||||
|
||||
preStartMessages(name, value)
|
||||
|
|
@ -88,7 +89,7 @@ func RunCallbacks(cc *config.ClusterConfig, name string, value string, options *
|
|||
if errors.Is(err, ErrSkipThisAddon) {
|
||||
return err
|
||||
}
|
||||
return errors.Wrap(err, "running callbacks")
|
||||
return fmt.Errorf("running callbacks: %w", err)
|
||||
}
|
||||
|
||||
postStartMessages(cc, name, value)
|
||||
|
|
@ -176,7 +177,7 @@ func Deprecations(name string) (bool, string, string) {
|
|||
func Set(cc *config.ClusterConfig, name string, value string, options *run.CommandOptions) error {
|
||||
a, valid := isAddonValid(name)
|
||||
if !valid {
|
||||
return errors.Errorf("%s is not a valid addon", name)
|
||||
return fmt.Errorf("%s is not a valid addon", name)
|
||||
}
|
||||
return a.set(cc, name, value, options)
|
||||
}
|
||||
|
|
@ -185,18 +186,18 @@ func Set(cc *config.ClusterConfig, name string, value string, options *run.Comma
|
|||
func SetAndSave(profile string, name string, value string, options *run.CommandOptions) error {
|
||||
cc, err := config.Load(profile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "loading profile")
|
||||
return fmt.Errorf("loading profile: %w", err)
|
||||
}
|
||||
|
||||
if err := RunCallbacks(cc, name, value, options); err != nil {
|
||||
if errors.Is(err, ErrSkipThisAddon) {
|
||||
return err
|
||||
}
|
||||
return errors.Wrap(err, "run callbacks")
|
||||
return fmt.Errorf("run callbacks: %w", err)
|
||||
}
|
||||
|
||||
if err := Set(cc, name, value, options); err != nil {
|
||||
return errors.Wrap(err, "set")
|
||||
return fmt.Errorf("set: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("Writing out %q config to set %s=%v...", profile, name, value)
|
||||
|
|
@ -239,7 +240,7 @@ func EnableOrDisableAddon(cc *config.ClusterConfig, name string, val string, opt
|
|||
klog.Infof("Setting addon %s=%s in %q", name, val, cc.Name)
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing bool: %s", name)
|
||||
return fmt.Errorf("parsing bool: %s: %w", name, err)
|
||||
}
|
||||
addon := assets.Addons[name]
|
||||
|
||||
|
|
@ -253,7 +254,7 @@ func EnableOrDisableAddon(cc *config.ClusterConfig, name string, val string, opt
|
|||
|
||||
api, err := machine.NewAPIClient(options)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "machine client")
|
||||
return fmt.Errorf("machine client: %w", err)
|
||||
}
|
||||
defer api.Close()
|
||||
|
||||
|
|
@ -288,7 +289,7 @@ func EnableOrDisableAddon(cc *config.ClusterConfig, name string, val string, opt
|
|||
|
||||
runner, err := machine.CommandRunner(host)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "command runner")
|
||||
return fmt.Errorf("command runner: %w", err)
|
||||
}
|
||||
|
||||
bail, err := addonSpecificChecks(cc, name, enable, runner)
|
||||
|
|
@ -336,7 +337,7 @@ func addonSpecificChecks(cc *config.ClusterConfig, name string, enable bool, run
|
|||
if driver.NeedsPortForward(cc.Driver) {
|
||||
port, err := oci.ForwardedPort(cc.Driver, cc.Name, constants.RegistryAddonPort)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "registry port")
|
||||
return false, fmt.Errorf("registry port: %w", err)
|
||||
}
|
||||
if enable {
|
||||
out.Boxed(`Registry addon with {{.driver}} driver uses port {{.port}} please use that instead of default port 5000`, out.V{"driver": cc.Driver, "port": port})
|
||||
|
|
@ -386,7 +387,7 @@ func isAddonAlreadySet(cc *config.ClusterConfig, addon *assets.Addon, enable boo
|
|||
func supportLegacyIngress(addon *assets.Addon, cc config.ClusterConfig) error {
|
||||
v, err := util.ParseKubernetesVersion(cc.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing Kubernetes version")
|
||||
return fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
if semver.MustParseRange("<1.19.0")(v) {
|
||||
if addon.Name() == "ingress" {
|
||||
|
|
@ -424,7 +425,7 @@ func enableOrDisableAddonInternal(cc *config.ClusterConfig, addon *assets.Addon,
|
|||
if addon.IsTemplate() {
|
||||
f, err = addon.Evaluate(data)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "evaluate bundled addon %s asset", addon.GetSourcePath())
|
||||
return fmt.Errorf("evaluate bundled addon %s asset: %w", addon.GetSourcePath(), err)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -495,7 +496,7 @@ func verifyAddonStatusInternal(cc *config.ClusterConfig, name string, val string
|
|||
klog.Infof("Verifying addon %s=%s in %q", name, val, cc.Name)
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing bool: %s", name)
|
||||
return fmt.Errorf("parsing bool: %s: %w", name, err)
|
||||
}
|
||||
|
||||
label, ok := addonPodLabels[name]
|
||||
|
|
@ -503,13 +504,13 @@ func verifyAddonStatusInternal(cc *config.ClusterConfig, name string, val string
|
|||
out.Step(style.HealthCheck, "Verifying {{.addon_name}} addon...", out.V{"addon_name": name})
|
||||
client, err := kapi.Client(viper.GetString(config.ProfileName))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get kube-client to validate %s addon: %v", name, err)
|
||||
return fmt.Errorf("get kube-client to validate %s addon: %v: %w", name, err, err)
|
||||
}
|
||||
|
||||
// This timeout includes image pull time, which can take a few minutes. 3 is not enough.
|
||||
err = kapi.WaitForPods(client, ns, label, time.Minute*6)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "waiting for %s pods", label)
|
||||
return fmt.Errorf("waiting for %s pods: %w", label, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -623,28 +624,28 @@ func VerifyNotPaused(profile string, enable bool, options *run.CommandOptions) e
|
|||
|
||||
cc, err := config.Load(profile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "loading profile")
|
||||
return fmt.Errorf("loading profile: %w", err)
|
||||
}
|
||||
|
||||
api, err := machine.NewAPIClient(options)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "machine client")
|
||||
return fmt.Errorf("machine client: %w", err)
|
||||
}
|
||||
defer api.Close()
|
||||
|
||||
cp, err := config.ControlPlane(*cc)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get control-plane node")
|
||||
return fmt.Errorf("get control-plane node: %w", err)
|
||||
}
|
||||
|
||||
host, err := machine.LoadHost(api, config.MachineName(*cc, cp))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get host")
|
||||
return fmt.Errorf("get host: %w", err)
|
||||
}
|
||||
|
||||
s, err := host.Driver.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get state")
|
||||
return fmt.Errorf("get state: %w", err)
|
||||
}
|
||||
if s != state.Running {
|
||||
// can't check the status of pods on a non-running cluster
|
||||
|
|
@ -653,17 +654,17 @@ func VerifyNotPaused(profile string, enable bool, options *run.CommandOptions) e
|
|||
|
||||
runner, err := machine.CommandRunner(host)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "command runner")
|
||||
return fmt.Errorf("command runner: %w", err)
|
||||
}
|
||||
|
||||
crName := cc.KubernetesConfig.ContainerRuntime
|
||||
cr, err := cruntime.New(cruntime.Config{Type: crName, Runner: runner})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "container runtime")
|
||||
return fmt.Errorf("container runtime: %w", err)
|
||||
}
|
||||
runtimePaused, err := cluster.CheckIfPaused(cr, []string{"kube-system"})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "check paused")
|
||||
return fmt.Errorf("check paused: %w", err)
|
||||
}
|
||||
if !runtimePaused {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ limitations under the License.
|
|||
package addons
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -36,7 +36,7 @@ import (
|
|||
func enableOrDisableAutoPause(cc *config.ClusterConfig, name, val string, options *run.CommandOptions) error {
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing bool: %s", name)
|
||||
return fmt.Errorf("parsing bool: %s: %w", name, err)
|
||||
}
|
||||
out.Infof("auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.")
|
||||
out.Infof("https://github.com/kubernetes/minikube/labels/co/auto-pause")
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/oauth2/google"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
|
|
@ -58,7 +57,7 @@ const (
|
|||
func enableOrDisableGCPAuth(cfg *config.ClusterConfig, name, val string, options *run.CommandOptions) error {
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing bool: %s", name)
|
||||
return fmt.Errorf("parsing bool: %s: %w", name, err)
|
||||
}
|
||||
if enable {
|
||||
return enableAddonGCPAuth(cfg, options)
|
||||
|
|
@ -90,7 +89,7 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig, options *run.CommandOptions)
|
|||
// Patch service accounts for all namespaces to include the image pull secret.
|
||||
// The image registry pull secret is added to the namespaces in the webhook.
|
||||
if err := patchServiceAccounts(cfg); err != nil {
|
||||
return errors.Wrap(err, "patching service accounts")
|
||||
return fmt.Errorf("patching service accounts: %w", err)
|
||||
}
|
||||
|
||||
// If the env var is explicitly set, even in GCE, then defer to the user and continue
|
||||
|
|
@ -307,7 +306,7 @@ func disableAddonGCPAuth(cfg *config.ClusterConfig, options *run.CommandOptions)
|
|||
func verifyGCPAuthAddon(cc *config.ClusterConfig, name, val string, options *run.CommandOptions) error {
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing bool: %s", name)
|
||||
return fmt.Errorf("parsing bool: %s: %w", name, err)
|
||||
}
|
||||
|
||||
// If we're in GCE and didn't actually start the gcp-auth pods, don't check for them.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ limitations under the License.
|
|||
package addons
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/machine"
|
||||
|
|
@ -34,7 +34,7 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st
|
|||
klog.Infof("enableOrDisableStorageClasses %s=%v on %q", name, val, cc.Name)
|
||||
enable, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error parsing boolean")
|
||||
return fmt.Errorf("Error parsing boolean: %w", err)
|
||||
}
|
||||
|
||||
class := defaultStorageClassProvisioner
|
||||
|
|
@ -44,13 +44,13 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st
|
|||
|
||||
api, err := machine.NewAPIClient(options)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "machine client")
|
||||
return fmt.Errorf("machine client: %w", err)
|
||||
}
|
||||
defer api.Close()
|
||||
|
||||
pcp, err := config.ControlPlane(*cc)
|
||||
if err != nil || !config.IsPrimaryControlPlane(*cc, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
return fmt.Errorf("get primary control-plane node: %w", err)
|
||||
}
|
||||
machineName := config.MachineName(*cc, pcp)
|
||||
if !machine.IsRunning(api, machineName) {
|
||||
|
|
@ -60,7 +60,7 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st
|
|||
|
||||
storagev1, err := storageclass.GetStoragev1(cc.Name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Error getting storagev1 interface %v ", err)
|
||||
return fmt.Errorf("Error getting storagev1 interface %v : %w", err, err)
|
||||
}
|
||||
|
||||
if enable {
|
||||
|
|
@ -71,13 +71,13 @@ func enableOrDisableStorageClasses(cc *config.ClusterConfig, name string, val st
|
|||
// Only StorageClass for 'name' should be marked as default
|
||||
err = storageclass.SetDefaultStorageClass(storagev1, class)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Error making %s the default storage class", class)
|
||||
return fmt.Errorf("Error making %s the default storage class: %w", class, err)
|
||||
}
|
||||
} else {
|
||||
// Unset the StorageClass as default
|
||||
err := storageclass.DisableDefaultStorageClass(storagev1, class)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Error disabling %s as the default storage class", class)
|
||||
return fmt.Errorf("Error disabling %s as the default storage class: %w", class, err)
|
||||
}
|
||||
if err = EnableOrDisableAddon(cc, name, val, options); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"os/exec"
|
||||
"path"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/vmpath"
|
||||
|
|
@ -80,19 +79,19 @@ func helmInstallBinary(addon *assets.Addon, runner command.Runner) error {
|
|||
if err != nil {
|
||||
_, err = runner.RunCmd(exec.Command("sudo", "mkdir", "-p", "/usr/local/bin"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating /usr/local/bin")
|
||||
return fmt.Errorf("creating /usr/local/bin: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
installCmd := "curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh"
|
||||
_, err = runner.RunCmd(exec.Command("sudo", "bash", "-c", installCmd))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "downloading helm")
|
||||
return fmt.Errorf("downloading helm: %w", err)
|
||||
}
|
||||
// we copy the binary from /usr/local/bin to /usr/bin because /usr/local/bin is not in PATH in both iso and kicbase
|
||||
_, err = runner.RunCmd(exec.Command("sudo", "mv", "/usr/local/bin/helm", "/usr/bin/helm"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "installing helm")
|
||||
return fmt.Errorf("installing helm: %w", err)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnflag"
|
||||
|
|
@ -69,17 +68,17 @@ func CreateRawDisk(diskPath string, sizeMB int) error {
|
|||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
// un-handle-able error stat-ing the disk file
|
||||
return errors.Wrap(err, "stat")
|
||||
return fmt.Errorf("stat: %w", err)
|
||||
}
|
||||
// disk file does not exist; create it
|
||||
file, err := os.OpenFile(diskPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "open")
|
||||
return fmt.Errorf("open: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err := file.Truncate(util.ConvertMBToBytes(sizeMB)); err != nil {
|
||||
return errors.Wrap(err, "truncate")
|
||||
return fmt.Errorf("truncate: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -108,27 +107,27 @@ func (d *CommonDriver) SetConfigFromFlags(_ drivers.DriverOptions) error {
|
|||
func createRawDiskImage(sshKeyPath, diskPath string, diskSizeMb int) error {
|
||||
tarBuf, err := mcnutils.MakeDiskImage(sshKeyPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "make disk image")
|
||||
return fmt.Errorf("make disk image: %w", err)
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(diskPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "open")
|
||||
return fmt.Errorf("open: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
if _, err := file.Seek(0, io.SeekStart); err != nil {
|
||||
return errors.Wrap(err, "seek")
|
||||
return fmt.Errorf("seek: %w", err)
|
||||
}
|
||||
|
||||
if _, err := file.Write(tarBuf.Bytes()); err != nil {
|
||||
return errors.Wrap(err, "write tar")
|
||||
return fmt.Errorf("write tar: %w", err)
|
||||
}
|
||||
if err := file.Close(); err != nil {
|
||||
return errors.Wrapf(err, "closing file %s", diskPath)
|
||||
return fmt.Errorf("closing file %s: %w", diskPath, err)
|
||||
}
|
||||
|
||||
if err := os.Truncate(diskPath, util.ConvertMBToBytes(diskSizeMb)); err != nil {
|
||||
return errors.Wrap(err, "truncate")
|
||||
return fmt.Errorf("truncate: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -152,24 +151,24 @@ func MakeDiskImage(d *drivers.BaseDriver, boot2dockerURL string, diskSize int) e
|
|||
klog.Infof("Making disk image using store path: %s", d.StorePath)
|
||||
b2 := mcnutils.NewB2dUtils(d.StorePath)
|
||||
if err := b2.CopyIsoToMachineDir(boot2dockerURL, d.MachineName); err != nil {
|
||||
return errors.Wrap(err, "copy iso to machine dir")
|
||||
return fmt.Errorf("copy iso to machine dir: %w", err)
|
||||
}
|
||||
|
||||
keyPath := d.GetSSHKeyPath()
|
||||
klog.Infof("Creating ssh key: %s...", keyPath)
|
||||
if err := ssh.GenerateSSHKey(keyPath); err != nil {
|
||||
return errors.Wrap(err, "generate ssh key")
|
||||
return fmt.Errorf("generate ssh key: %w", err)
|
||||
}
|
||||
|
||||
diskPath := GetDiskPath(d)
|
||||
klog.Infof("Creating raw disk image: %s...", diskPath)
|
||||
if _, err := os.Stat(diskPath); os.IsNotExist(err) {
|
||||
if err := createRawDiskImage(publicSSHKeyPath(d), diskPath, diskSize); err != nil {
|
||||
return errors.Wrapf(err, "createRawDiskImage(%s)", diskPath)
|
||||
return fmt.Errorf("createRawDiskImage(%s): %w", diskPath, err)
|
||||
}
|
||||
machPath := d.ResolveStorePath(".")
|
||||
if err := fixMachinePermissions(machPath); err != nil {
|
||||
return errors.Wrapf(err, "fixing permissions on %s", machPath)
|
||||
return fmt.Errorf("fixing permissions on %s: %w", machPath, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -178,16 +177,16 @@ func MakeDiskImage(d *drivers.BaseDriver, boot2dockerURL string, diskSize int) e
|
|||
func fixMachinePermissions(path string) error {
|
||||
klog.Infof("Fixing permissions on %s ...", path)
|
||||
if err := os.Chown(path, syscall.Getuid(), syscall.Getegid()); err != nil {
|
||||
return errors.Wrap(err, "chown dir")
|
||||
return fmt.Errorf("chown dir: %w", err)
|
||||
}
|
||||
files, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read dir")
|
||||
return fmt.Errorf("read dir: %w", err)
|
||||
}
|
||||
for _, f := range files {
|
||||
fp := filepath.Join(path, f.Name())
|
||||
if err := os.Chown(fp, syscall.Getuid(), syscall.Getegid()); err != nil {
|
||||
return errors.Wrap(err, "chown file")
|
||||
return fmt.Errorf("chown file: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
pkgerrors "errors"
|
||||
|
||||
"github.com/johanneswuerbach/nfsexports"
|
||||
hyperkit "github.com/moby/hyperkit/go"
|
||||
pkgerrors "github.com/pkg/errors"
|
||||
"github.com/shirou/gopsutil/v4/process"
|
||||
"k8s.io/minikube/pkg/drivers/common"
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/ssh"
|
||||
|
|
@ -173,12 +172,12 @@ func (d *Driver) Create() error {
|
|||
} else {
|
||||
// The conflicting container name was not created by minikube
|
||||
// user has a container that conflicts with minikube profile name, will not delete users container.
|
||||
return errors.Wrapf(err, "user has a conflicting container name %q with minikube container. Needs to be deleted by user's consent", params.Name)
|
||||
return fmt.Errorf("user has a conflicting container name %q with minikube container. Needs to be deleted by user's consent: %w", params.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := oci.PrepareContainerNode(params); err != nil {
|
||||
return errors.Wrap(err, "setting up container node")
|
||||
return fmt.Errorf("setting up container node: %w", err)
|
||||
}
|
||||
|
||||
var waitForPreload sync.WaitGroup
|
||||
|
|
@ -209,11 +208,11 @@ func (d *Driver) Create() error {
|
|||
}
|
||||
|
||||
if err := oci.CreateContainerNode(params); err != nil {
|
||||
return errors.Wrap(err, "create kic node")
|
||||
return fmt.Errorf("create kic node: %w", err)
|
||||
}
|
||||
|
||||
if err := d.prepareSSH(); err != nil {
|
||||
return errors.Wrap(err, "prepare kic ssh")
|
||||
return fmt.Errorf("prepare kic ssh: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -224,13 +223,13 @@ func (d *Driver) prepareSSH() error {
|
|||
keyPath := d.GetSSHKeyPath()
|
||||
klog.Infof("Creating ssh key for kic: %s...", keyPath)
|
||||
if err := ssh.GenerateSSHKey(keyPath); err != nil {
|
||||
return errors.Wrap(err, "generate ssh key")
|
||||
return fmt.Errorf("generate ssh key: %w", err)
|
||||
}
|
||||
|
||||
cmder := command.NewKICRunner(d.NodeConfig.MachineName, d.NodeConfig.OCIBinary)
|
||||
f, err := assets.NewFileAsset(d.GetSSHKeyPath()+".pub", "/home/docker/.ssh/", "authorized_keys", "0644")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create pubkey assetfile ")
|
||||
return fmt.Errorf("create pubkey assetfile : %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
|
|
@ -239,7 +238,7 @@ func (d *Driver) prepareSSH() error {
|
|||
}()
|
||||
|
||||
if err := cmder.Copy(f); err != nil {
|
||||
return errors.Wrap(err, "copying pub key")
|
||||
return fmt.Errorf("copying pub key: %w", err)
|
||||
}
|
||||
|
||||
// Double-check that the container has not crashed so that we may give a better error message
|
||||
|
|
@ -250,11 +249,11 @@ func (d *Driver) prepareSSH() error {
|
|||
|
||||
if s != state.Running {
|
||||
excerpt := oci.LogContainerDebug(d.OCIBinary, d.MachineName)
|
||||
return errors.Wrapf(oci.ErrExitedUnexpectedly, "container name %q state %s: log: %s", d.MachineName, s, excerpt)
|
||||
return fmt.Errorf("container name %q state %s: log: %s: %w", d.MachineName, s, excerpt, oci.ErrExitedUnexpectedly)
|
||||
}
|
||||
|
||||
if rr, err := cmder.RunCmd(exec.Command("chown", "docker:docker", "/home/docker/.ssh/authorized_keys")); err != nil {
|
||||
return errors.Wrapf(err, "apply authorized_keys file ownership, output %s", rr.Output())
|
||||
return fmt.Errorf("apply authorized_keys file ownership, output %s: %w", rr.Output(), err)
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
|
|
@ -275,7 +274,7 @@ func (d *Driver) prepareSSH() error {
|
|||
icaclsCmdOut, icaclsCmdErr := icaclsCmd.CombinedOutput()
|
||||
|
||||
if icaclsCmdErr != nil {
|
||||
return errors.Wrap(icaclsCmdErr, fmt.Sprintf("unable to execute icacls to set permissions: %s", icaclsCmdOut))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("unable to execute icacls to set permissions: %s", icaclsCmdOut), icaclsCmdErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,7 +310,7 @@ func (d *Driver) GetSSHHostname() (string, error) {
|
|||
func (d *Driver) GetSSHPort() (int, error) {
|
||||
p, err := oci.ForwardedPort(d.OCIBinary, d.MachineName, constants.SSHPort)
|
||||
if err != nil {
|
||||
return p, errors.Wrap(err, "get ssh host-port")
|
||||
return p, fmt.Errorf("get ssh host-port: %w", err)
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
|
@ -360,7 +359,7 @@ func (d *Driver) Kill() error {
|
|||
|
||||
cr := command.NewExecRunner(false) // using exec runner for interacting with daemon.
|
||||
if _, err := cr.RunCmd(oci.PrefixCmd(exec.Command(d.NodeConfig.OCIBinary, "kill", d.MachineName))); err != nil {
|
||||
return errors.Wrapf(err, "killing %q", d.MachineName)
|
||||
return fmt.Errorf("killing %q: %w", d.MachineName, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -373,7 +372,7 @@ func (d *Driver) Remove() error {
|
|||
|
||||
if err := oci.DeleteContainer(context.Background(), d.NodeConfig.OCIBinary, d.MachineName); err != nil {
|
||||
if strings.Contains(err.Error(), "is already in progress") {
|
||||
return errors.Wrap(err, "stuck delete")
|
||||
return fmt.Errorf("stuck delete: %w", err)
|
||||
}
|
||||
if strings.Contains(err.Error(), "No such container:") {
|
||||
return nil // nothing was found to delete.
|
||||
|
|
@ -415,9 +414,9 @@ func (d *Driver) Start() error {
|
|||
if err := oci.StartContainer(d.NodeConfig.OCIBinary, d.MachineName); err != nil {
|
||||
oci.LogContainerDebug(d.OCIBinary, d.MachineName)
|
||||
if _, err := oci.DaemonInfo(d.OCIBinary); err != nil {
|
||||
return errors.Wrapf(oci.ErrDaemonInfo, "debug daemon info %q", d.MachineName)
|
||||
return fmt.Errorf("debug daemon info %q: %w", d.MachineName, oci.ErrDaemonInfo)
|
||||
}
|
||||
return errors.Wrap(err, "start")
|
||||
return fmt.Errorf("start: %w", err)
|
||||
}
|
||||
checkRunning := func() error {
|
||||
s, err := oci.ContainerStatus(d.NodeConfig.OCIBinary, d.MachineName)
|
||||
|
|
@ -435,10 +434,10 @@ func (d *Driver) Start() error {
|
|||
excerpt := oci.LogContainerDebug(d.OCIBinary, d.MachineName)
|
||||
_, err := oci.DaemonInfo(d.OCIBinary)
|
||||
if err != nil {
|
||||
return errors.Wrapf(oci.ErrDaemonInfo, "container name %q", d.MachineName)
|
||||
return fmt.Errorf("container name %q: %w", d.MachineName, oci.ErrDaemonInfo)
|
||||
}
|
||||
|
||||
return errors.Wrapf(oci.ErrExitedUnexpectedly, "container name %q: log: %s", d.MachineName, excerpt)
|
||||
return fmt.Errorf("container name %q: log: %s: %w", d.MachineName, excerpt, oci.ErrExitedUnexpectedly)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -483,7 +482,7 @@ func (d *Driver) Stop() error {
|
|||
|
||||
cmd := exec.Command(d.NodeConfig.OCIBinary, "stop", d.MachineName)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrapf(err, "stopping %s", d.MachineName)
|
||||
return fmt.Errorf("stopping %s: %w", d.MachineName, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -503,7 +502,7 @@ func killAPIServerProc(runner command.Runner) error {
|
|||
if err == nil { // this means we have a valid pid
|
||||
klog.Warningf("Found a kube-apiserver running with pid %d, will try to kill the proc", pid)
|
||||
if _, err = runner.RunCmd(exec.Command("pkill", "-9", fmt.Sprint(pid))); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ package oci
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
|
|
@ -256,11 +256,11 @@ func dockerSystemInfo() (dockerSysInfo, error) {
|
|||
rawJSON, err := dockerInfoGetter()
|
||||
if err != nil {
|
||||
klog.Warningf("docker info: %v", err)
|
||||
return ds, errors.Wrap(err, "docker system info")
|
||||
return ds, fmt.Errorf("docker system info: %w", err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(strings.TrimSpace(rawJSON)), &ds); err != nil {
|
||||
klog.Warningf("unmarshal docker info: %v", err)
|
||||
return ds, errors.Wrapf(err, "unmarshal docker system info")
|
||||
return ds, fmt.Errorf("unmarshal docker system info: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("docker info: %+v", ds)
|
||||
|
|
@ -278,12 +278,12 @@ func podmanSystemInfo() (podmanSysInfo, error) {
|
|||
rawJSON, err := podmanInfoGetter()
|
||||
if err != nil {
|
||||
klog.Warningf("podman info: %v", err)
|
||||
return ps, errors.Wrap(err, "podman system info")
|
||||
return ps, fmt.Errorf("podman system info: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(strings.TrimSpace(rawJSON)), &ps); err != nil {
|
||||
klog.Warningf("unmarshal podman info: %v", err)
|
||||
return ps, errors.Wrapf(err, "unmarshal podman system info")
|
||||
return ps, fmt.Errorf("unmarshal podman system info: %w", err)
|
||||
}
|
||||
klog.Infof("podman info: %+v", ps)
|
||||
return ps, nil
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
|
|
@ -70,7 +71,7 @@ func RoutableHostIPFromInside(ociBin string, clusterName string, containerName s
|
|||
|
||||
return containerGatewayIP(Docker, containerName)
|
||||
}
|
||||
return info.gateway, errors.Wrap(err, "network inspect")
|
||||
return info.gateway, fmt.Errorf("network inspect: %w", err)
|
||||
}
|
||||
return info.gateway, nil
|
||||
}
|
||||
|
|
@ -90,7 +91,7 @@ func digDNS(ociBin, containerName, dns string) (net.IP, error) {
|
|||
rr, err := runCmd(exec.Command(ociBin, "exec", "-t", containerName, "dig", "+short", dns))
|
||||
ip := net.ParseIP(strings.TrimSpace(rr.Stdout.String()))
|
||||
if err != nil {
|
||||
return ip, errors.Wrapf(err, "resolve dns to ip")
|
||||
return ip, fmt.Errorf("resolve dns to ip: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("got host ip for mount in container by digging dns: %s", ip.String())
|
||||
|
|
@ -101,7 +102,7 @@ func digDNS(ociBin, containerName, dns string) (net.IP, error) {
|
|||
func gatewayIP(ociBin, containerName string) (string, error) {
|
||||
rr, err := runCmd(exec.Command(ociBin, "container", "inspect", "--format", "{{.NetworkSettings.Gateway}}", containerName))
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "inspect gateway")
|
||||
return "", fmt.Errorf("inspect gateway: %w", err)
|
||||
}
|
||||
if gatewayIP := strings.TrimSpace(rr.Stdout.String()); gatewayIP != "" {
|
||||
return gatewayIP, nil
|
||||
|
|
@ -133,7 +134,7 @@ func networkGateway(ociBin, container, network string) (string, error) {
|
|||
`, network, network)
|
||||
rr, err := runCmd(exec.Command(ociBin, "container", "inspect", "--format", format, container))
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "inspect gateway")
|
||||
return "", fmt.Errorf("inspect gateway: %w", err)
|
||||
}
|
||||
return strings.TrimSpace(rr.Stdout.String()), nil
|
||||
}
|
||||
|
|
@ -142,7 +143,7 @@ func networkGateway(ociBin, container, network string) (string, error) {
|
|||
func containerGatewayIP(ociBin string, containerName string) (net.IP, error) {
|
||||
gatewayIP, err := gatewayIP(ociBin, containerName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "inspect gateway")
|
||||
return nil, fmt.Errorf("inspect gateway: %w", err)
|
||||
}
|
||||
return net.ParseIP(gatewayIP), nil
|
||||
}
|
||||
|
|
@ -160,7 +161,7 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) {
|
|||
if ociBin == Podman {
|
||||
v, err = podmanVersion()
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "podman version")
|
||||
return 0, fmt.Errorf("podman version: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +169,7 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) {
|
|||
if ociBin == Podman && v.LT(semver.Version{Major: 2, Minor: 0, Patch: 1}) {
|
||||
rr, err = runCmd(exec.Command(ociBin, "container", "inspect", "-f", fmt.Sprintf("{{range .NetworkSettings.Ports}}{{if eq .ContainerPort %s}}{{.HostPort}}{{end}}{{end}}", fmt.Sprint(contPort)), ociID))
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "get port %d for %q", contPort, ociID)
|
||||
return 0, fmt.Errorf("get port %d for %q: %w", contPort, ociID, err)
|
||||
}
|
||||
} else {
|
||||
rr, err = runCmd(exec.Command(ociBin, "container", "inspect", "-f", fmt.Sprintf("'{{(index (index .NetworkSettings.Ports \"%d/tcp\") 0).HostPort}}'", contPort), ociID))
|
||||
|
|
@ -181,7 +182,7 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) {
|
|||
if strings.Contains(rr.Output(), "error calling index: index of untyped nil") {
|
||||
return 0, ErrGetPortContainerNotRunning
|
||||
}
|
||||
return 0, errors.Wrapf(err, "get port %d for %q", contPort, ociID)
|
||||
return 0, fmt.Errorf("get port %d for %q: %w", contPort, ociID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ func ForwardedPort(ociBin string, ociID string, contPort int) (int, error) {
|
|||
p, err := strconv.Atoi(o)
|
||||
|
||||
if err != nil {
|
||||
return p, errors.Wrapf(err, "convert host-port %q to number", p)
|
||||
return p, fmt.Errorf("convert host-port %q to number: %w", p, err)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
|
|
@ -210,7 +211,7 @@ func podmanContainerIP(ociBin string, name string) (string, string, error) {
|
|||
"-f", "{{.NetworkSettings.IPAddress}}",
|
||||
name))
|
||||
if err != nil {
|
||||
return "", "", errors.Wrapf(err, "podman inspect ip %s", name)
|
||||
return "", "", fmt.Errorf("podman inspect ip %s: %w", name, err)
|
||||
}
|
||||
output := strings.TrimSpace(rr.Stdout.String())
|
||||
if output == "" { // podman returns empty for 127.0.0.1
|
||||
|
|
@ -229,16 +230,16 @@ func dockerContainerIP(ociBin string, name string) (string, string, error) {
|
|||
// retrieve the IP address of the node using docker inspect
|
||||
lines, err := inspect(ociBin, name, "{{range .NetworkSettings.Networks}}{{.IPAddress}},{{.GlobalIPv6Address}}{{end}}")
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "inspecting NetworkSettings.Networks")
|
||||
return "", "", fmt.Errorf("inspecting NetworkSettings.Networks: %w", err)
|
||||
}
|
||||
|
||||
if len(lines) != 1 {
|
||||
return "", "", errors.Errorf("IPs output should only be one line, got %d lines", len(lines))
|
||||
return "", "", fmt.Errorf("IPs output should only be one line, got %d lines", len(lines))
|
||||
}
|
||||
|
||||
ips := strings.Split(lines[0], ",")
|
||||
if len(ips) != 2 {
|
||||
return "", "", errors.Errorf("container addresses should have 2 values, got %d values: %+v", len(ips), ips)
|
||||
return "", "", fmt.Errorf("container addresses should have 2 values, got %d values: %+v", len(ips), ips)
|
||||
}
|
||||
return ips[0], ips[1], nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/network"
|
||||
|
|
@ -227,7 +228,7 @@ func dockerNetworkInspect(name string) (netInfo, error) {
|
|||
|
||||
_, info.subnet, err = net.ParseCIDR(vals.Subnet)
|
||||
if err != nil {
|
||||
return info, errors.Wrapf(err, "parse subnet for %s", name)
|
||||
return info, fmt.Errorf("parse subnet for %s: %w", name, err)
|
||||
}
|
||||
|
||||
return info, nil
|
||||
|
|
@ -236,7 +237,7 @@ func dockerNetworkInspect(name string) (netInfo, error) {
|
|||
var podmanInspectGetter = func(name string) (*RunResult, error) {
|
||||
v, err := podmanVersion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "podman version")
|
||||
return nil, fmt.Errorf("podman version: %w", err)
|
||||
}
|
||||
format := `{{range .}}{{if eq .Driver "bridge"}}{{(index .Subnets 0).Subnet}},{{(index .Subnets 0).Gateway}}{{end}}{{end}}`
|
||||
if v.LT(semver.Version{Major: 4, Minor: 0, Patch: 0}) {
|
||||
|
|
@ -273,7 +274,7 @@ func podmanNetworkInspect(name string) (netInfo, error) {
|
|||
|
||||
_, info.subnet, err = net.ParseCIDR(vals[0])
|
||||
if err != nil {
|
||||
return info, errors.Wrapf(err, "parse subnet for %s", name)
|
||||
return info, fmt.Errorf("parse subnet for %s: %w", name, err)
|
||||
}
|
||||
|
||||
return info, nil
|
||||
|
|
@ -337,7 +338,7 @@ func DeleteKICNetworksByLabel(ociBin string, label string) []error {
|
|||
var errs []error
|
||||
ns, err := networkNamesByLabel(ociBin, label)
|
||||
if err != nil {
|
||||
return []error{errors.Wrap(err, "list all volume")}
|
||||
return []error{fmt.Errorf("list all volume: %w", err)}
|
||||
}
|
||||
for _, n := range ns {
|
||||
err := RemoveNetwork(ociBin, n)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/state"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
|
@ -59,7 +58,7 @@ func DeleteContainersByLabel(ociBin string, label string) []error {
|
|||
// only try to delete if docker/podman inspect returns
|
||||
// if it doesn't it means docker daemon is stuck and needs restart
|
||||
if err != nil {
|
||||
deleteErrs = append(deleteErrs, errors.Wrapf(err, "delete container %s: %s daemon is stuck. please try again", c, ociBin))
|
||||
deleteErrs = append(deleteErrs, fmt.Errorf("delete container %s: %s daemon is stuck. please try again: %w", c, ociBin, err))
|
||||
klog.Errorf("%s daemon seems to be stuck. please try restarting your %s :%v", ociBin, ociBin, err)
|
||||
continue
|
||||
}
|
||||
|
|
@ -68,7 +67,7 @@ func DeleteContainersByLabel(ociBin string, label string) []error {
|
|||
}
|
||||
|
||||
if _, err := runCmd(exec.Command(ociBin, "rm", "-f", "-v", c)); err != nil {
|
||||
deleteErrs = append(deleteErrs, errors.Wrapf(err, "delete container %s: output %s", c, err))
|
||||
deleteErrs = append(deleteErrs, fmt.Errorf("delete container %s: output %s: %w", c, err, err))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -89,7 +88,7 @@ func DeleteContainer(ctx context.Context, ociBin string, name string) error {
|
|||
}
|
||||
|
||||
if _, err := runCmd(exec.CommandContext(ctx, ociBin, "rm", "-f", "-v", name)); err != nil {
|
||||
return errors.Wrapf(err, "delete %s", name)
|
||||
return fmt.Errorf("delete %s: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -98,11 +97,11 @@ func DeleteContainer(ctx context.Context, ociBin string, name string) error {
|
|||
// For the container runtime, it creates a volume which will be mounted into kic
|
||||
func PrepareContainerNode(p CreateParams) error {
|
||||
if err := createVolume(p.OCIBinary, p.Name, p.Name); err != nil {
|
||||
return errors.Wrapf(err, "creating volume for %s container", p.Name)
|
||||
return fmt.Errorf("creating volume for %s container: %w", p.Name, err)
|
||||
}
|
||||
klog.Infof("Successfully created a %s volume %s", p.OCIBinary, p.Name)
|
||||
if err := prepareVolumeSideCar(p.OCIBinary, p.Image, p.Name); err != nil {
|
||||
return errors.Wrapf(err, "preparing volume for %s container", p.Name)
|
||||
return fmt.Errorf("preparing volume for %s container: %w", p.Name, err)
|
||||
}
|
||||
klog.Infof("Successfully prepared a %s volume %s", p.OCIBinary, p.Name)
|
||||
return nil
|
||||
|
|
@ -156,7 +155,7 @@ func CreateContainerNode(p CreateParams) error { //nolint to suppress cyclomatic
|
|||
}
|
||||
if err != nil {
|
||||
klog.Warningf("error getting daemon info: %v", err)
|
||||
return errors.Wrap(err, "daemon info")
|
||||
return fmt.Errorf("daemon info: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,17 +272,17 @@ func CreateContainerNode(p CreateParams) error { //nolint to suppress cyclomatic
|
|||
}
|
||||
|
||||
if err := createContainer(p.OCIBinary, p.Image, withRunArgs(runArgs...), withMounts(p.Mounts), withPortMappings(p.PortMappings)); err != nil {
|
||||
return errors.Wrap(err, "create container")
|
||||
return fmt.Errorf("create container: %w", err)
|
||||
}
|
||||
|
||||
if err := retry.Expo(checkRunning(p), 15*time.Millisecond, 25*time.Second); err != nil {
|
||||
excerpt := LogContainerDebug(p.OCIBinary, p.Name)
|
||||
_, err := DaemonInfo(p.OCIBinary)
|
||||
if err != nil {
|
||||
return errors.Wrapf(ErrDaemonInfo, "container name %q", p.Name)
|
||||
return fmt.Errorf("container name %q: %w", p.Name, ErrDaemonInfo)
|
||||
}
|
||||
|
||||
return errors.Wrapf(ErrExitedUnexpectedly, "container name %q: log: %s", p.Name, excerpt)
|
||||
return fmt.Errorf("container name %q: log: %s: %w", p.Name, excerpt, ErrExitedUnexpectedly)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -596,12 +595,12 @@ func resetEnv(key string) error {
|
|||
v := os.Getenv(constants.MinikubeExistingPrefix + key)
|
||||
if v == "" {
|
||||
if err := os.Unsetenv(key); err != nil {
|
||||
return errors.Wrapf(err, "resetting %s env", key)
|
||||
return fmt.Errorf("resetting %s env: %w", key, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := os.Setenv(key, v); err != nil {
|
||||
return errors.Wrapf(err, "resetting %s env", key)
|
||||
return fmt.Errorf("resetting %s env: %w", key, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -647,7 +646,7 @@ func ContainerStatus(ociBin string, name string, warnSlow ...bool) (state.State,
|
|||
case "dead":
|
||||
return state.Error, nil
|
||||
default:
|
||||
return state.None, errors.Wrapf(err, "unknown state %q", name)
|
||||
return state.None, fmt.Errorf("unknown state %q: %w", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -671,10 +670,10 @@ func ShutDown(ociBin string, name string) error {
|
|||
klog.Infof("temporary error verifying shutdown: %v", err)
|
||||
}
|
||||
klog.Infof("temporary error: container %s status is %s but expect it to be exited", name, st)
|
||||
return errors.Wrap(err, "couldn't verify container is exited. %v")
|
||||
return fmt.Errorf("couldn't verify container is exited: %w", err)
|
||||
}
|
||||
if err := retry.Expo(stopped, time.Millisecond*500, time.Second*20); err != nil {
|
||||
return errors.Wrap(err, "verify shutdown")
|
||||
return fmt.Errorf("verify shutdown: %w", err)
|
||||
}
|
||||
klog.Infof("Successfully shutdown container %s", name)
|
||||
return nil
|
||||
|
|
@ -743,7 +742,7 @@ func IsExternalDaemonHost(driver string) bool {
|
|||
func podmanVersion() (semver.Version, error) {
|
||||
rr, err := runCmd(exec.Command(Podman, "version", "--format", "{{.Version}}"))
|
||||
if err != nil {
|
||||
return semver.Version{}, errors.Wrapf(err, "podman version")
|
||||
return semver.Version{}, fmt.Errorf("podman version: %w", err)
|
||||
}
|
||||
output := strings.TrimSpace(rr.Stdout.String())
|
||||
return semver.Make(output)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
|
@ -101,7 +101,7 @@ func PruneAllVolumesByLabel(ctx context.Context, ociBin string, label string, wa
|
|||
klog.Infof("trying to prune all %s volumes with label %s", ociBin, label)
|
||||
cmd := exec.CommandContext(ctx, ociBin, "volume", "prune", "-f", "--filter", "label="+label)
|
||||
if _, err := runCmd(cmd, warnSlow...); err != nil {
|
||||
deleteErrs = append(deleteErrs, errors.Wrapf(err, "prune volume by label %s", label))
|
||||
deleteErrs = append(deleteErrs, fmt.Errorf("prune volume by label %s: %w", label, err))
|
||||
}
|
||||
|
||||
return deleteErrs
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnutils"
|
||||
|
|
@ -282,7 +283,7 @@ func (d *Driver) setupIP(mac string) error {
|
|||
getIP := func() error {
|
||||
d.IPAddress, err = common.GetIPAddressByMACAddress(mac)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get IP address")
|
||||
return fmt.Errorf("failed to get IP address: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -301,7 +302,7 @@ func (d *Driver) setupIP(mac string) error {
|
|||
return nil
|
||||
}
|
||||
if !isBootpdError(err) {
|
||||
return errors.Wrap(err, "IP address never found in dhcp leases file")
|
||||
return fmt.Errorf("IP address never found in dhcp leases file: %w", err)
|
||||
}
|
||||
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
|
||||
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
|
||||
|
|
@ -332,11 +333,11 @@ func (d *Driver) Kill() error {
|
|||
func (d *Driver) Remove() error {
|
||||
s, err := d.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get state")
|
||||
return fmt.Errorf("get state: %w", err)
|
||||
}
|
||||
if s == state.Running {
|
||||
if err := d.Kill(); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"libvirt.org/go/libvirt"
|
||||
)
|
||||
|
|
@ -71,7 +70,7 @@ func (d *Driver) defineDomain() (*libvirt.Domain, error) {
|
|||
tmpl := template.Must(template.New("domain").Parse(domainTmpl))
|
||||
var domainXML bytes.Buffer
|
||||
if err := tmpl.Execute(&domainXML, d); err != nil {
|
||||
return nil, errors.Wrap(err, "executing domain xml")
|
||||
return nil, fmt.Errorf("executing domain xml: %w", err)
|
||||
}
|
||||
conn, err := getConnection(d.ConnectionURI)
|
||||
if err != nil {
|
||||
|
|
@ -86,7 +85,7 @@ func (d *Driver) defineDomain() (*libvirt.Domain, error) {
|
|||
log.Infof("defining domain using XML: %v", domainXML.String())
|
||||
dom, err := conn.DomainDefineXML(domainXML.String())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error defining domain xml: %s", domainXML.String())
|
||||
return nil, fmt.Errorf("error defining domain xml: %s: %w", domainXML.String(), err)
|
||||
}
|
||||
|
||||
// save MAC address
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/drivers/common"
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
|
|
@ -39,12 +40,12 @@ import (
|
|||
// more info https://github.com/docker/machine/blob/b170508bf44c3405e079e26d5fdffe35a64c6972/libmachine/provision/utils.go#L159_L175
|
||||
func (d *Driver) GetURL() (string, error) {
|
||||
if err := d.PreCommandCheck(); err != nil {
|
||||
return "", errors.Wrap(err, "prechecking")
|
||||
return "", fmt.Errorf("prechecking: %w", err)
|
||||
}
|
||||
|
||||
ip, err := d.GetIP()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "getting domain IP")
|
||||
return "", fmt.Errorf("getting domain IP: %w", err)
|
||||
}
|
||||
|
||||
if ip == "" {
|
||||
|
|
@ -68,7 +69,7 @@ func (d *Driver) PreCommandCheck() error {
|
|||
|
||||
libVersion, err := conn.GetLibVersion()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting libvirt version")
|
||||
return fmt.Errorf("getting libvirt version: %w", err)
|
||||
}
|
||||
|
||||
log.Debugf("using libvirt version %d", libVersion)
|
||||
|
|
@ -80,7 +81,7 @@ func (d *Driver) PreCommandCheck() error {
|
|||
func (d *Driver) GetState() (state.State, error) {
|
||||
dom, conn, err := d.getDomain()
|
||||
if err != nil {
|
||||
return state.None, errors.Wrap(err, "getting domain")
|
||||
return state.None, fmt.Errorf("getting domain: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := closeDomain(dom, conn); err != nil {
|
||||
|
|
@ -90,7 +91,7 @@ func (d *Driver) GetState() (state.State, error) {
|
|||
|
||||
lvs, _, err := dom.GetState() // state, reason, error
|
||||
if err != nil {
|
||||
return state.None, errors.Wrap(err, "getting domain state")
|
||||
return state.None, fmt.Errorf("getting domain state: %w", err)
|
||||
}
|
||||
|
||||
return machineState(lvs), nil
|
||||
|
|
@ -133,7 +134,7 @@ func machineState(lvs libvirt.DomainState) state.State {
|
|||
func (d *Driver) GetIP() (string, error) {
|
||||
s, err := d.GetState()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "getting domain state")
|
||||
return "", fmt.Errorf("getting domain state: %w", err)
|
||||
}
|
||||
|
||||
if s != state.Running {
|
||||
|
|
@ -167,7 +168,7 @@ func (d *Driver) DriverName() string {
|
|||
func (d *Driver) Kill() error {
|
||||
s, err := d.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting domain state")
|
||||
return fmt.Errorf("getting domain state: %w", err)
|
||||
}
|
||||
|
||||
if s == state.Stopped {
|
||||
|
|
@ -178,7 +179,7 @@ func (d *Driver) Kill() error {
|
|||
|
||||
dom, conn, err := d.getDomain()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting domain")
|
||||
return fmt.Errorf("getting domain: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := closeDomain(dom, conn); err != nil {
|
||||
|
|
@ -210,13 +211,13 @@ func (d *Driver) Start() error {
|
|||
// this call ensures that all networks are active
|
||||
log.Info("ensuring networks are active...")
|
||||
if err := d.ensureNetwork(); err != nil {
|
||||
return errors.Wrap(err, "ensuring active networks")
|
||||
return fmt.Errorf("ensuring active networks: %w", err)
|
||||
}
|
||||
|
||||
log.Info("getting domain XML...")
|
||||
dom, conn, err := d.getDomain()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting domain XML")
|
||||
return fmt.Errorf("getting domain XML: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := closeDomain(dom, conn); err != nil {
|
||||
|
|
@ -232,23 +233,23 @@ func (d *Driver) Start() error {
|
|||
}
|
||||
|
||||
if err := dom.Create(); err != nil {
|
||||
return errors.Wrap(err, "creating domain")
|
||||
return fmt.Errorf("creating domain: %w", err)
|
||||
}
|
||||
|
||||
log.Info("waiting for domain to start...")
|
||||
if err := d.waitForDomainState(state.Running, 30*time.Second); err != nil {
|
||||
return errors.Wrap(err, "waiting for domain to start")
|
||||
return fmt.Errorf("waiting for domain to start: %w", err)
|
||||
}
|
||||
log.Info("domain is now running")
|
||||
|
||||
log.Info("waiting for IP...")
|
||||
if err := d.waitForStaticIP(conn, 90*time.Second); err != nil {
|
||||
return errors.Wrap(err, "waiting for IP")
|
||||
return fmt.Errorf("waiting for IP: %w", err)
|
||||
}
|
||||
|
||||
log.Info("waiting for SSH...")
|
||||
if err := drivers.WaitForSSH(d); err != nil {
|
||||
return errors.Wrap(err, "waiting for SSH")
|
||||
return fmt.Errorf("waiting for SSH: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -280,7 +281,7 @@ func (d *Driver) waitForStaticIP(conn *libvirt.Connect, maxTime time.Duration) e
|
|||
query := func() error {
|
||||
sip, err := ipFromAPI(conn, d.MachineName, d.PrivateNetwork)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting domain IP, will retry")
|
||||
return fmt.Errorf("getting domain IP, will retry: %w", err)
|
||||
}
|
||||
|
||||
if sip == "" {
|
||||
|
|
@ -312,14 +313,14 @@ func (d *Driver) Create() error {
|
|||
|
||||
log.Info("creating network...")
|
||||
if err := d.createNetwork(); err != nil {
|
||||
return errors.Wrap(err, "creating network")
|
||||
return fmt.Errorf("creating network: %w", err)
|
||||
}
|
||||
|
||||
if d.GPU {
|
||||
log.Info("getting devices XML...")
|
||||
xml, err := getDevicesXML()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting devices XML")
|
||||
return fmt.Errorf("getting devices XML: %w", err)
|
||||
}
|
||||
d.DevicesXML = xml
|
||||
}
|
||||
|
|
@ -327,7 +328,7 @@ func (d *Driver) Create() error {
|
|||
if d.NUMANodeCount > 1 {
|
||||
numaXML, err := numaXML(d.CPU, d.Memory, d.NUMANodeCount)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating NUMA XML")
|
||||
return fmt.Errorf("creating NUMA XML: %w", err)
|
||||
}
|
||||
d.NUMANodeXML = numaXML
|
||||
}
|
||||
|
|
@ -336,12 +337,12 @@ func (d *Driver) Create() error {
|
|||
log.Infof("setting up store path in %s ...", store)
|
||||
// 0755 because it must be accessible by libvirt/qemu across a variety of configs
|
||||
if err := os.MkdirAll(store, 0755); err != nil {
|
||||
return errors.Wrap(err, "creating store")
|
||||
return fmt.Errorf("creating store: %w", err)
|
||||
}
|
||||
|
||||
log.Infof("building disk image from %s", d.Boot2DockerURL)
|
||||
if err := common.MakeDiskImage(d.BaseDriver, d.Boot2DockerURL, d.DiskSize); err != nil {
|
||||
return errors.Wrap(err, "creating disk")
|
||||
return fmt.Errorf("creating disk: %w", err)
|
||||
}
|
||||
|
||||
if d.ExtraDisks > 20 {
|
||||
|
|
@ -353,13 +354,13 @@ func (d *Driver) Create() error {
|
|||
for i := 0; i < d.ExtraDisks; i++ {
|
||||
diskpath := common.ExtraDiskPath(d.BaseDriver, i)
|
||||
if err := common.CreateRawDisk(diskpath, d.DiskSize); err != nil {
|
||||
return errors.Wrap(err, "creating extra disks")
|
||||
return fmt.Errorf("creating extra disks: %w", err)
|
||||
}
|
||||
// Starting the logical names for the extra disks from hdd as the cdrom device is set to hdc.
|
||||
// TODO: Enhance the domain template to use variable for the logical name of the main disk and the cdrom disk.
|
||||
extraDisksXML, err := getExtraDiskXML(diskpath, fmt.Sprintf("hd%v", string(rune('d'+i))))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating extraDisk XML")
|
||||
return fmt.Errorf("creating extraDisk XML: %w", err)
|
||||
}
|
||||
d.ExtraDisksXML = append(d.ExtraDisksXML, extraDisksXML)
|
||||
}
|
||||
|
|
@ -371,7 +372,7 @@ func (d *Driver) Create() error {
|
|||
log.Info("defining domain...")
|
||||
dom, err := d.defineDomain()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "defining domain")
|
||||
return fmt.Errorf("defining domain: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if dom == nil {
|
||||
|
|
@ -382,7 +383,7 @@ func (d *Driver) Create() error {
|
|||
}()
|
||||
|
||||
if err := d.Start(); err != nil {
|
||||
return errors.Wrap(err, "starting domain")
|
||||
return fmt.Errorf("starting domain: %w", err)
|
||||
}
|
||||
|
||||
log.Infof("domain creation complete")
|
||||
|
|
@ -513,11 +514,11 @@ func (d *Driver) Remove() error {
|
|||
|
||||
log.Infof("domain %s exists, removing...", d.MachineName)
|
||||
if err := d.destroyRunningDomain(dom); err != nil {
|
||||
return errors.Wrap(err, "destroying running domain")
|
||||
return fmt.Errorf("destroying running domain: %w", err)
|
||||
}
|
||||
|
||||
if err := d.undefineDomain(conn, dom); err != nil {
|
||||
return errors.Wrap(err, "undefining domain")
|
||||
return fmt.Errorf("undefining domain: %w", err)
|
||||
}
|
||||
|
||||
log.Info("removing static IP address...")
|
||||
|
|
@ -535,7 +536,7 @@ func (d *Driver) Remove() error {
|
|||
func (d *Driver) destroyRunningDomain(dom *libvirt.Domain) error {
|
||||
lvs, _, err := dom.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting domain state")
|
||||
return fmt.Errorf("getting domain state: %w", err)
|
||||
}
|
||||
|
||||
// if the domain is not running, we don't destroy it
|
||||
|
|
@ -550,7 +551,7 @@ func (d *Driver) destroyRunningDomain(dom *libvirt.Domain) error {
|
|||
func (d *Driver) undefineDomain(conn *libvirt.Connect, dom *libvirt.Domain) error {
|
||||
definedDomains, err := conn.ListDefinedDomains()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "listing domains")
|
||||
return fmt.Errorf("listing domains: %w", err)
|
||||
}
|
||||
|
||||
var found bool
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"k8s.io/minikube/pkg/network"
|
||||
"k8s.io/minikube/pkg/util/retry"
|
||||
|
|
@ -97,24 +96,24 @@ func setupNetwork(conn *libvirt.Connect, name string) error {
|
|||
// always ensure autostart is set on the network
|
||||
autostart, err := n.GetAutostart()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "checking network %s autostart", name)
|
||||
return fmt.Errorf("checking network %s autostart: %w", name, err)
|
||||
}
|
||||
if !autostart {
|
||||
if err := n.SetAutostart(true); err != nil {
|
||||
return errors.Wrapf(err, "setting autostart for network %s", name)
|
||||
return fmt.Errorf("setting autostart for network %s: %w", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
// always ensure the network is started (active)
|
||||
active, err := n.IsActive()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "checking network status for %s", name)
|
||||
return fmt.Errorf("checking network status for %s: %w", name, err)
|
||||
}
|
||||
|
||||
if !active {
|
||||
log.Debugf("network %s is not active, trying to start it...", name)
|
||||
if err := n.Create(); err != nil {
|
||||
return errors.Wrapf(err, "starting network %s", name)
|
||||
return fmt.Errorf("starting network %s: %w", name, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -148,11 +147,11 @@ func (d *Driver) ensureNetwork() error {
|
|||
if err := setupNetwork(conn, d.PrivateNetwork); err != nil {
|
||||
log.Debugf("Network %s is inoperable, will try to recreate it: %v", d.PrivateNetwork, err)
|
||||
if err := d.deleteNetwork(); err != nil {
|
||||
return errors.Wrapf(err, "deleting inoperable network %s", d.PrivateNetwork)
|
||||
return fmt.Errorf("deleting inoperable network %s: %w", d.PrivateNetwork, err)
|
||||
}
|
||||
log.Debugf("Successfully deleted %s network", d.PrivateNetwork)
|
||||
if err := d.createNetwork(); err != nil {
|
||||
return errors.Wrapf(err, "recreating inoperable network %s", d.PrivateNetwork)
|
||||
return fmt.Errorf("recreating inoperable network %s: %w", d.PrivateNetwork, err)
|
||||
}
|
||||
log.Debugf("Successfully recreated %s network", d.PrivateNetwork)
|
||||
if err := setupNetwork(conn, d.PrivateNetwork); err != nil {
|
||||
|
|
@ -293,7 +292,7 @@ func (d *Driver) deleteNetwork() error {
|
|||
log.Warnf("Network %s does not exist. Skipping deletion", d.PrivateNetwork)
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "failed looking up network %s", d.PrivateNetwork)
|
||||
return fmt.Errorf("failed looking up network %s: %w", d.PrivateNetwork, err)
|
||||
}
|
||||
defer func() {
|
||||
if libvirtNet == nil {
|
||||
|
|
@ -328,7 +327,7 @@ func (d *Driver) deleteNetwork() error {
|
|||
return libvirtNet.Undefine()
|
||||
}
|
||||
if err := retry.Local(deleteFunc, 10*time.Second); err != nil {
|
||||
return errors.Wrap(err, "deleting network")
|
||||
return fmt.Errorf("deleting network: %w", err)
|
||||
}
|
||||
log.Debugf("Network %s deleted", d.PrivateNetwork)
|
||||
|
||||
|
|
@ -356,7 +355,7 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error {
|
|||
log.Debug("Trying to list all domains...")
|
||||
doms, err := conn.ListAllDomains(0)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list all domains")
|
||||
return fmt.Errorf("list all domains: %w", err)
|
||||
}
|
||||
log.Debugf("Listed all domains: total of %d domains", len(doms))
|
||||
|
||||
|
|
@ -370,7 +369,7 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error {
|
|||
log.Debug("Trying to get name of domain...")
|
||||
name, err := dom.GetName()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get name of a domain")
|
||||
return fmt.Errorf("failed to get name of a domain: %w", err)
|
||||
}
|
||||
log.Debugf("Got domain name: %s", name)
|
||||
|
||||
|
|
@ -386,14 +385,14 @@ func (d *Driver) checkDomains(conn *libvirt.Connect) error {
|
|||
log.Debugf("Getting XML for domain %s...", name)
|
||||
xmlString, err := dom.GetXMLDesc(libvirt.DOMAIN_XML_INACTIVE)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get XML of domain '%s'", name)
|
||||
return fmt.Errorf("failed to get XML of domain '%s': %w", name, err)
|
||||
}
|
||||
log.Debugf("Got XML for domain %s", name)
|
||||
|
||||
v := result{}
|
||||
err = xml.Unmarshal([]byte(xmlString), &v)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to unmarshal XML of domain '%s", name)
|
||||
return fmt.Errorf("failed to unmarshal XML of domain '%s: %w", name, err)
|
||||
}
|
||||
log.Debugf("Unmarshaled XML for domain %s: %#v", name, v)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
knet "k8s.io/apimachinery/pkg/util/net"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/drivers/common"
|
||||
|
|
@ -157,25 +156,25 @@ func (d *Driver) Kill() error {
|
|||
// First try to gracefully stop containers
|
||||
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "containers")
|
||||
return fmt.Errorf("containers: %w", err)
|
||||
}
|
||||
if len(containers) == 0 {
|
||||
return nil
|
||||
}
|
||||
// Try to be graceful before sending SIGKILL everywhere.
|
||||
if err := d.runtime.StopContainers(containers); err != nil {
|
||||
return errors.Wrap(err, "stop")
|
||||
return fmt.Errorf("stop: %w", err)
|
||||
}
|
||||
|
||||
containers, err = d.runtime.ListContainers(cruntime.ListContainersOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "containers")
|
||||
return fmt.Errorf("containers: %w", err)
|
||||
}
|
||||
if len(containers) == 0 {
|
||||
return nil
|
||||
}
|
||||
if err := d.runtime.KillContainers(containers); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -183,7 +182,7 @@ func (d *Driver) Kill() error {
|
|||
// Remove a host, including any data which may have been written by it.
|
||||
func (d *Driver) Remove() error {
|
||||
if err := d.Kill(); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
klog.Infof("Removing: %s", cleanupPaths)
|
||||
args := append([]string{"rm", "-rf"}, cleanupPaths...)
|
||||
|
|
@ -223,22 +222,22 @@ func (d *Driver) Stop() error {
|
|||
// Stop running containers
|
||||
running, err := d.runtime.ListContainers(cruntime.ListContainersOptions{State: cruntime.Running})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list running containers")
|
||||
return fmt.Errorf("list running containers: %w", err)
|
||||
}
|
||||
if len(running) > 0 {
|
||||
if err := d.runtime.StopContainers(running); err != nil {
|
||||
return errors.Wrap(err, "stop running containers")
|
||||
return fmt.Errorf("stop running containers: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Stop paused containers
|
||||
paused, err := d.runtime.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list paused containers")
|
||||
return fmt.Errorf("list paused containers: %w", err)
|
||||
}
|
||||
if len(paused) > 0 {
|
||||
if err := d.runtime.StopContainers(paused); err != nil {
|
||||
return errors.Wrap(err, "stop paused containers")
|
||||
return fmt.Errorf("stop paused containers: %w", err)
|
||||
}
|
||||
}
|
||||
klog.Infof("none driver is stopped!")
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnutils"
|
||||
|
|
@ -313,12 +314,12 @@ func parsePortRange(rawPortRange string) (int, int, error) {
|
|||
|
||||
minPort, err := strconv.Atoi(portRange[0])
|
||||
if err != nil {
|
||||
return 0, 0, errors.Wrap(err, "invalid min port range")
|
||||
return 0, 0, fmt.Errorf("invalid min port range: %w", err)
|
||||
}
|
||||
|
||||
maxPort, err := strconv.Atoi(portRange[1])
|
||||
if err != nil {
|
||||
return 0, 0, errors.Wrap(err, "invalid max port range")
|
||||
return 0, 0, fmt.Errorf("invalid max port range: %w", err)
|
||||
}
|
||||
|
||||
if maxPort < minPort {
|
||||
|
|
@ -515,7 +516,7 @@ func (d *Driver) Start() error {
|
|||
getIP := func() error {
|
||||
d.IPAddress, err = common.GetIPAddressByMACAddress(d.MACAddress)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get IP address")
|
||||
return fmt.Errorf("failed to get IP address: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -538,7 +539,7 @@ func (d *Driver) Start() error {
|
|||
break
|
||||
}
|
||||
if !isBootpdError(err) {
|
||||
return errors.Wrap(err, "IP address never found in dhcp leases file")
|
||||
return fmt.Errorf("IP address never found in dhcp leases file: %w", err)
|
||||
}
|
||||
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
|
||||
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
|
||||
|
|
@ -616,16 +617,16 @@ func (d *Driver) Stop() error {
|
|||
func (d *Driver) Remove() error {
|
||||
s, err := d.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get state")
|
||||
return fmt.Errorf("get state: %w", err)
|
||||
}
|
||||
if s == state.Running {
|
||||
if err := d.Kill(); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
}
|
||||
if s != state.Stopped {
|
||||
if _, err := d.RunQMPCommand("quit"); err != nil {
|
||||
return errors.Wrap(err, "quit")
|
||||
return fmt.Errorf("quit: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -785,7 +786,7 @@ func (d *Driver) RunQMPCommand(command string) (map[string]interface{}, error) {
|
|||
// connect to monitor
|
||||
conn, err := net.Dial("unix", d.monitorPath())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "connect")
|
||||
return nil, fmt.Errorf("connect: %w", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
|
|
@ -793,7 +794,7 @@ func (d *Driver) RunQMPCommand(command string) (map[string]interface{}, error) {
|
|||
var buf [1024]byte
|
||||
nr, err := conn.Read(buf[:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "read initial resp")
|
||||
return nil, fmt.Errorf("read initial resp: %w", err)
|
||||
}
|
||||
type qmpInitialResponse struct {
|
||||
QMP struct {
|
||||
|
|
@ -811,7 +812,7 @@ func (d *Driver) RunQMPCommand(command string) (map[string]interface{}, error) {
|
|||
|
||||
var initialResponse qmpInitialResponse
|
||||
if err := json.Unmarshal(buf[:nr], &initialResponse); err != nil {
|
||||
return nil, errors.Wrap(err, "unmarshal initial resp")
|
||||
return nil, fmt.Errorf("unmarshal initial resp: %w", err)
|
||||
}
|
||||
|
||||
// run 'qmp_capabilities' to switch to command mode
|
||||
|
|
@ -821,21 +822,21 @@ func (d *Driver) RunQMPCommand(command string) (map[string]interface{}, error) {
|
|||
}
|
||||
jsonCommand, err := json.Marshal(qmpCommand{Command: "qmp_capabilities"})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "marshal qmp_capabilities")
|
||||
return nil, fmt.Errorf("marshal qmp_capabilities: %w", err)
|
||||
}
|
||||
if _, err := conn.Write(jsonCommand); err != nil {
|
||||
return nil, errors.Wrap(err, "write qmp_capabilities")
|
||||
return nil, fmt.Errorf("write qmp_capabilities: %w", err)
|
||||
}
|
||||
nr, err = conn.Read(buf[:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "read qmp_capabilities resp")
|
||||
return nil, fmt.Errorf("read qmp_capabilities resp: %w", err)
|
||||
}
|
||||
type qmpResponse struct {
|
||||
Return map[string]interface{} `json:"return"`
|
||||
}
|
||||
var response qmpResponse
|
||||
if err := json.Unmarshal(buf[:nr], &response); err != nil {
|
||||
return nil, errors.Wrap(err, "unmarshal qmp_capabilities resp")
|
||||
return nil, fmt.Errorf("unmarshal qmp_capabilities resp: %w", err)
|
||||
}
|
||||
// expecting empty response
|
||||
if len(response.Return) != 0 {
|
||||
|
|
@ -845,21 +846,21 @@ func (d *Driver) RunQMPCommand(command string) (map[string]interface{}, error) {
|
|||
// { "execute": command }
|
||||
jsonCommand, err = json.Marshal(qmpCommand{Command: command})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "marshal command")
|
||||
return nil, fmt.Errorf("marshal command: %w", err)
|
||||
}
|
||||
if _, err := conn.Write(jsonCommand); err != nil {
|
||||
return nil, errors.Wrap(err, "write command")
|
||||
return nil, fmt.Errorf("write command: %w", err)
|
||||
}
|
||||
nr, err = conn.Read(buf[:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "read command resp")
|
||||
return nil, fmt.Errorf("read command resp: %w", err)
|
||||
}
|
||||
|
||||
// Sometimes QEMU returns two JSON objects with the first object being the command response
|
||||
// and the second object being an event log (unimportant)
|
||||
firstRespObj := strings.Split(string(buf[:nr]), "\n")[0]
|
||||
if err := json.Unmarshal([]byte(firstRespObj), &response); err != nil {
|
||||
return nil, errors.Wrap(err, "unmarshal command resp")
|
||||
return nil, fmt.Errorf("unmarshal command resp: %w", err)
|
||||
}
|
||||
if strings.HasPrefix(command, "query-") {
|
||||
return response.Return, nil
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/drivers/common"
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
|
|
@ -117,7 +116,7 @@ func (d *Driver) PreCreateCheck() error {
|
|||
|
||||
_, err = ssh.ParsePrivateKey(key)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "SSH key does not parse: %q", d.SSHKey)
|
||||
return fmt.Errorf("SSH key does not parse: %q: %w", d.SSHKey, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,11 +143,11 @@ func (d *Driver) Create() error {
|
|||
if d.runtime.Name() == "Docker" {
|
||||
groups, err := d.exec.RunCmd(exec.Command("groups", d.GetSSHUsername()))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "groups")
|
||||
return fmt.Errorf("groups: %w", err)
|
||||
}
|
||||
if !strings.Contains(groups.Stdout.String(), "docker") {
|
||||
if _, err := d.exec.RunCmd(exec.Command("sudo", "usermod", "-aG", "docker", d.GetSSHUsername())); err != nil {
|
||||
return errors.Wrap(err, "usermod")
|
||||
return fmt.Errorf("usermod: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -199,11 +198,11 @@ func (d *Driver) Stop() error {
|
|||
}
|
||||
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "containers")
|
||||
return fmt.Errorf("containers: %w", err)
|
||||
}
|
||||
if len(containers) > 0 {
|
||||
if err := d.runtime.StopContainers(containers); err != nil {
|
||||
return errors.Wrap(err, "stop containers")
|
||||
return fmt.Errorf("stop containers: %w", err)
|
||||
}
|
||||
}
|
||||
klog.Infof("ssh driver is stopped!")
|
||||
|
|
@ -224,25 +223,25 @@ func (d *Driver) Kill() error {
|
|||
// First try to gracefully stop containers
|
||||
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "containers")
|
||||
return fmt.Errorf("containers: %w", err)
|
||||
}
|
||||
if len(containers) == 0 {
|
||||
return nil
|
||||
}
|
||||
// Try to be graceful before sending SIGKILL everywhere.
|
||||
if err := d.runtime.StopContainers(containers); err != nil {
|
||||
return errors.Wrap(err, "stop")
|
||||
return fmt.Errorf("stop: %w", err)
|
||||
}
|
||||
|
||||
containers, err = d.runtime.ListContainers(cruntime.ListContainersOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "containers")
|
||||
return fmt.Errorf("containers: %w", err)
|
||||
}
|
||||
if len(containers) == 0 {
|
||||
return nil
|
||||
}
|
||||
if err := d.runtime.KillContainers(containers); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnutils"
|
||||
|
|
@ -420,7 +421,7 @@ func (d *Driver) setupIP(mac string) error {
|
|||
getIP := func() error {
|
||||
d.IPAddress, err = common.GetIPAddressByMACAddress(mac)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get IP address")
|
||||
return fmt.Errorf("failed to get IP address: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -443,7 +444,7 @@ func (d *Driver) setupIP(mac string) error {
|
|||
return nil
|
||||
}
|
||||
if !isBootpdError(err) {
|
||||
return errors.Wrap(err, "IP address never found in dhcp leases file")
|
||||
return fmt.Errorf("IP address never found in dhcp leases file: %w", err)
|
||||
}
|
||||
if unblockErr := firewall.UnblockBootpd(&d.CommandOptions); unblockErr != nil {
|
||||
klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
|
||||
|
|
@ -508,11 +509,11 @@ func (d *Driver) Stop() error {
|
|||
func (d *Driver) Remove() error {
|
||||
s, err := d.GetState()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get state")
|
||||
return fmt.Errorf("get state: %w", err)
|
||||
}
|
||||
if s == state.Running {
|
||||
if err := d.Kill(); err != nil {
|
||||
return errors.Wrap(err, "kill")
|
||||
return fmt.Errorf("kill: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/libmachine/drivers"
|
||||
"k8s.io/minikube/pkg/libmachine/log"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
|
@ -40,15 +39,15 @@ func Docs(root *cobra.Command, path string, testPath string, codePath string) er
|
|||
}
|
||||
contents, err := DocForCommand(c)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "generating doc for %s", c.Name())
|
||||
return fmt.Errorf("generating doc for %s: %w", c.Name(), err)
|
||||
}
|
||||
if err := saveDocForCommand(c, []byte(contents), path); err != nil {
|
||||
return errors.Wrapf(err, "saving doc for %s", c.Name())
|
||||
return fmt.Errorf("saving doc for %s: %w", c.Name(), err)
|
||||
}
|
||||
}
|
||||
err := TestDocs(testPath, "test/integration")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to generate test docs")
|
||||
return fmt.Errorf("failed to generate test docs: %w", err)
|
||||
}
|
||||
|
||||
return ErrorCodes(codePath, []string{"pkg/minikube/reason/reason.go", "pkg/minikube/reason/exitcodes.go"})
|
||||
|
|
@ -58,16 +57,16 @@ func Docs(root *cobra.Command, path string, testPath string, codePath string) er
|
|||
func DocForCommand(command *cobra.Command) (string, error) {
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
if err := generateTitle(command, buf); err != nil {
|
||||
return "", errors.Wrap(err, "generating title")
|
||||
return "", fmt.Errorf("generating title: %w", err)
|
||||
}
|
||||
if err := rewriteLogFile(); err != nil {
|
||||
return "", errors.Wrap(err, "rewriting log_file")
|
||||
return "", fmt.Errorf("rewriting log_file: %w", err)
|
||||
}
|
||||
if err := rewriteFlags(command); err != nil {
|
||||
return "", errors.Wrap(err, "rewriting flags")
|
||||
return "", fmt.Errorf("rewriting flags: %w", err)
|
||||
}
|
||||
if err := writeSubcommands(command, buf); err != nil {
|
||||
return "", errors.Wrap(err, "writing subcommands")
|
||||
return "", fmt.Errorf("writing subcommands: %w", err)
|
||||
}
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
|
@ -139,7 +138,7 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command) error {
|
|||
// writeSubcommands recursively appends all subcommands to the doc
|
||||
func writeSubcommands(command *cobra.Command, w io.Writer) error {
|
||||
if err := GenMarkdown(command, w); err != nil {
|
||||
return errors.Wrapf(err, "getting markdown custom")
|
||||
return fmt.Errorf("getting markdown custom: %w", err)
|
||||
}
|
||||
if !command.HasSubCommands() {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
)
|
||||
|
||||
|
|
@ -44,11 +43,11 @@ func ErrorCodes(docPath string, pathsToCheck []string) error {
|
|||
for _, pathToCheck := range pathsToCheck {
|
||||
r, err := os.ReadFile(pathToCheck)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading file %s", pathToCheck))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("error reading file %s", pathToCheck), err)
|
||||
}
|
||||
file, err := parser.ParseFile(fset, "", r, parser.ParseComments)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error parsing file %s", pathToCheck))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("error parsing file %s", pathToCheck), err)
|
||||
}
|
||||
|
||||
if strings.Contains(pathToCheck, "exitcodes.go") {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
)
|
||||
|
||||
|
|
@ -50,11 +49,11 @@ func TestDocs(docPath string, pathToCheck string) error {
|
|||
fset := token.NewFileSet()
|
||||
r, e := os.ReadFile(path)
|
||||
if e != nil {
|
||||
return errors.Wrap(e, fmt.Sprintf("error reading file %s", path))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("error reading file %s", path), e)
|
||||
}
|
||||
file, e := parser.ParseFile(fset, "", r, parser.ParseComments)
|
||||
if e != nil {
|
||||
return errors.Wrap(e, fmt.Sprintf("error parsing file %s", path))
|
||||
return fmt.Errorf("%s: %w", fmt.Sprintf("error parsing file %s", path), e)
|
||||
}
|
||||
|
||||
ast.Inspect(file, func(x ast.Node) bool {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
|||
package gvisor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnutils"
|
||||
)
|
||||
|
||||
|
|
@ -29,15 +29,15 @@ import (
|
|||
func Disable() error {
|
||||
log.Print("Disabling gvisor...")
|
||||
if err := os.Remove(filepath.Join(nodeDir, containerdConfigPath)); err != nil {
|
||||
return errors.Wrapf(err, "removing %s", containerdConfigPath)
|
||||
return fmt.Errorf("removing %s: %w", containerdConfigPath, err)
|
||||
}
|
||||
log.Printf("Restoring default config.toml at %s", containerdConfigPath)
|
||||
if err := mcnutils.CopyFile(filepath.Join(nodeDir, containerdConfigBackupPath), filepath.Join(nodeDir, containerdConfigPath)); err != nil {
|
||||
return errors.Wrap(err, "reverting back to default config.toml")
|
||||
return fmt.Errorf("reverting back to default config.toml: %w", err)
|
||||
}
|
||||
// restart containerd
|
||||
if err := restartContainerd(); err != nil {
|
||||
return errors.Wrap(err, "restarting containerd")
|
||||
return fmt.Errorf("restarting containerd: %w", err)
|
||||
}
|
||||
log.Print("Successfully disabled gvisor")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine/mcnutils"
|
||||
)
|
||||
|
||||
|
|
@ -67,16 +66,16 @@ func releaseURL() string {
|
|||
// 4. restarts containerd
|
||||
func Enable() error {
|
||||
if err := makeGvisorDirs(); err != nil {
|
||||
return errors.Wrap(err, "creating directories on node")
|
||||
return fmt.Errorf("creating directories on node: %w", err)
|
||||
}
|
||||
if err := downloadBinaries(); err != nil {
|
||||
return errors.Wrap(err, "downloading binaries")
|
||||
return fmt.Errorf("downloading binaries: %w", err)
|
||||
}
|
||||
if err := configure(); err != nil {
|
||||
return errors.Wrap(err, "copying config files")
|
||||
return fmt.Errorf("copying config files: %w", err)
|
||||
}
|
||||
if err := restartContainerd(); err != nil {
|
||||
return errors.Wrap(err, "restarting containerd")
|
||||
return fmt.Errorf("restarting containerd: %w", err)
|
||||
}
|
||||
// When pod is terminated, disable gvisor and exit
|
||||
c := make(chan os.Signal, 1)
|
||||
|
|
@ -99,13 +98,13 @@ func makeGvisorDirs() error {
|
|||
// Make /run/containerd/runsc to hold logs
|
||||
fp := filepath.Join(nodeDir, "run/containerd/runsc")
|
||||
if err := os.MkdirAll(fp, 0755); err != nil {
|
||||
return errors.Wrap(err, "creating runsc dir")
|
||||
return fmt.Errorf("creating runsc dir: %w", err)
|
||||
}
|
||||
|
||||
// Make /tmp/runsc to also hold logs
|
||||
fp = filepath.Join(nodeDir, "tmp/runsc")
|
||||
if err := os.MkdirAll(fp, 0755); err != nil {
|
||||
return errors.Wrap(err, "creating runsc logs dir")
|
||||
return fmt.Errorf("creating runsc logs dir: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -113,10 +112,10 @@ func makeGvisorDirs() error {
|
|||
|
||||
func downloadBinaries() error {
|
||||
if err := runsc(); err != nil {
|
||||
return errors.Wrap(err, "downloading runsc")
|
||||
return fmt.Errorf("downloading runsc: %w", err)
|
||||
}
|
||||
if err := gvisorContainerdShim(); err != nil {
|
||||
return errors.Wrap(err, "downloading gvisor-containerd-shim")
|
||||
return fmt.Errorf("downloading gvisor-containerd-shim: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -139,7 +138,7 @@ func downloadFileToDest(url, dest string) error {
|
|||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "creating request for %s", url)
|
||||
return fmt.Errorf("creating request for %s: %w", url, err)
|
||||
}
|
||||
req.Header.Set("User-Agent", "minikube")
|
||||
resp, err := client.Do(req)
|
||||
|
|
@ -149,19 +148,19 @@ func downloadFileToDest(url, dest string) error {
|
|||
defer resp.Body.Close()
|
||||
if _, err := os.Stat(dest); err == nil {
|
||||
if err := os.Remove(dest); err != nil {
|
||||
return errors.Wrapf(err, "removing %s for overwrite", dest)
|
||||
return fmt.Errorf("removing %s for overwrite: %w", dest, err)
|
||||
}
|
||||
}
|
||||
fi, err := os.Create(dest)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "creating %s", dest)
|
||||
return fmt.Errorf("creating %s: %w", dest, err)
|
||||
}
|
||||
defer fi.Close()
|
||||
if _, err := io.Copy(fi, resp.Body); err != nil {
|
||||
return errors.Wrap(err, "copying binary")
|
||||
return fmt.Errorf("copying binary: %w", err)
|
||||
}
|
||||
if err := fi.Chmod(0777); err != nil {
|
||||
return errors.Wrap(err, "fixing perms")
|
||||
return fmt.Errorf("fixing perms: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -173,7 +172,7 @@ func configure() error {
|
|||
log.Printf("Storing default config.toml at %s", containerdConfigBackupPath)
|
||||
configPath := filepath.Join(nodeDir, containerdConfigPath)
|
||||
if err := mcnutils.CopyFile(configPath, filepath.Join(nodeDir, containerdConfigBackupPath)); err != nil {
|
||||
return errors.Wrap(err, "copying default config.toml")
|
||||
return fmt.Errorf("copying default config.toml: %w", err)
|
||||
}
|
||||
|
||||
// Append runsc configuration to contained config.
|
||||
|
|
@ -182,7 +181,7 @@ func configure() error {
|
|||
return err
|
||||
}
|
||||
if _, err := config.WriteString(configFragment); err != nil {
|
||||
return errors.Wrap(err, "changing config.toml")
|
||||
return fmt.Errorf("changing config.toml: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -194,21 +193,21 @@ func restartContainerd() error {
|
|||
cmd := exec.Command("/usr/sbin/chroot", "/node", "sudo", "systemctl", "stop", "rpc-statd.service")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
fmt.Println(string(out))
|
||||
return errors.Wrap(err, "stopping rpc-statd.service")
|
||||
return fmt.Errorf("stopping rpc-statd.service: %w", err)
|
||||
}
|
||||
|
||||
log.Print("Restarting containerd...")
|
||||
cmd = exec.Command("/usr/sbin/chroot", "/node", "sudo", "systemctl", "restart", "containerd")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Print(string(out))
|
||||
return errors.Wrap(err, "restarting containerd")
|
||||
return fmt.Errorf("restarting containerd: %w", err)
|
||||
}
|
||||
|
||||
log.Print("Starting rpc-statd...")
|
||||
cmd = exec.Command("/usr/sbin/chroot", "/node", "sudo", "systemctl", "start", "rpc-statd.service")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Print(string(out))
|
||||
return errors.Wrap(err, "restarting rpc-statd.service")
|
||||
return fmt.Errorf("restarting rpc-statd.service: %w", err)
|
||||
}
|
||||
log.Print("containerd restart complete")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"time"
|
||||
|
||||
semver "github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/deploy/addons"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -909,7 +908,7 @@ func GenerateTemplateData(addon *Addon, cc *config.ClusterConfig, netInfo Networ
|
|||
|
||||
v, err := util.ParseKubernetesVersion(cfg.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing Kubernetes version")
|
||||
return fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
|
||||
opts := struct {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
|
@ -165,7 +165,7 @@ func NewFileAsset(src, targetDir, targetName, permissions string) (*FileAsset, e
|
|||
|
||||
info, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "stat")
|
||||
return nil, fmt.Errorf("stat: %w", err)
|
||||
}
|
||||
|
||||
if info.Size() == 0 {
|
||||
|
|
@ -174,7 +174,7 @@ func NewFileAsset(src, targetDir, targetName, permissions string) (*FileAsset, e
|
|||
|
||||
f, err := os.Open(src)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "open")
|
||||
return nil, fmt.Errorf("open: %w", err)
|
||||
}
|
||||
|
||||
return &FileAsset{
|
||||
|
|
@ -385,7 +385,7 @@ func (m *BinAsset) IsTemplate() bool {
|
|||
// Evaluate evaluates the template to a new asset
|
||||
func (m *BinAsset) Evaluate(data interface{}) (*MemoryAsset, error) {
|
||||
if !m.IsTemplate() {
|
||||
return nil, errors.Errorf("the asset %s is not a template", m.SourcePath)
|
||||
return nil, fmt.Errorf("the asset %s is not a template", m.SourcePath)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ func TransferBinaries(cfg config.KubernetesConfig, c command.Runner, sm sysinit.
|
|||
g.Go(func() error {
|
||||
src, err := download.Binary(name, cfg.KubernetesVersion, "linux", runtime.GOARCH, binariesURL)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "downloading %s", name)
|
||||
return fmt.Errorf("downloading %s: %w", name, err)
|
||||
}
|
||||
|
||||
if name == "kubelet" && sm.Active(name) {
|
||||
|
|
@ -76,7 +75,7 @@ func TransferBinaries(cfg config.KubernetesConfig, c command.Runner, sm sysinit.
|
|||
|
||||
dst := path.Join(dir, name)
|
||||
if err := copyBinary(c, src, dst); err != nil {
|
||||
return errors.Wrapf(err, "copybinary %s -> %s", src, dst)
|
||||
return fmt.Errorf("copybinary %s -> %s: %w", src, dst, err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
@ -113,7 +112,7 @@ func binRoot(version string) string {
|
|||
func copyBinary(cr command.Runner, src, dest string) error {
|
||||
f, err := assets.NewFileAsset(src, path.Dir(dest), path.Base(dest), "0755")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "new file asset")
|
||||
return fmt.Errorf("new file asset: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
|
|
@ -122,7 +121,7 @@ func copyBinary(cr command.Runner, src, dest string) error {
|
|||
}()
|
||||
|
||||
if err := cr.Copy(f); err != nil {
|
||||
return errors.Wrapf(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
)
|
||||
|
|
@ -116,7 +115,7 @@ func FindInvalidExtraConfigFlags(opts config.ExtraOptionSlice) []string {
|
|||
func extraConfigForComponent(component string, opts config.ExtraOptionSlice, version semver.Version) (map[string]string, error) {
|
||||
versionedOpts, err := defaultOptionsForComponentAndVersion(component, version)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "setting version specific options for %s", component)
|
||||
return nil, fmt.Errorf("setting version specific options for %s: %w", component, err)
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
|
@ -161,7 +160,7 @@ func newComponentOptions(opts config.ExtraOptionSlice, version semver.Version, f
|
|||
}
|
||||
extraConfig, err := extraConfigForComponent(component, opts, version)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "getting kubeadm extra args for %s", component)
|
||||
return nil, fmt.Errorf("getting kubeadm extra args for %s: %w", component, err)
|
||||
}
|
||||
if featureGates != "" {
|
||||
extraConfig["feature-gates"] = featureGates
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/third_party/kubeadm/app/features"
|
||||
)
|
||||
|
||||
|
|
@ -60,7 +59,7 @@ func parseFeatureArgs(featureGates string) (map[string]bool, string, error) {
|
|||
|
||||
boolValue, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil, "", errors.Wrapf(err, "failed to convert bool value \"%v\"", v)
|
||||
return nil, "", fmt.Errorf("failed to convert bool value \"%v\": %w", v, err)
|
||||
}
|
||||
kubeadmFeatureArgs[k] = boolValue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ limitations under the License.
|
|||
package bsutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
)
|
||||
|
|
@ -44,12 +44,12 @@ func CopyFiles(runner command.Runner, files []assets.CopyableFile) error {
|
|||
}
|
||||
args := append([]string{"mkdir", "-p"}, dirs...)
|
||||
if _, err := runner.RunCmd(exec.Command("sudo", args...)); err != nil {
|
||||
return errors.Wrap(err, "mkdir")
|
||||
return fmt.Errorf("mkdir: %w", err)
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if err := runner.Copy(f); err != nil {
|
||||
return errors.Wrapf(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"slices"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/ktmpl"
|
||||
|
|
@ -44,13 +43,13 @@ func GenerateKubeadmYAML(cc config.ClusterConfig, n config.Node, r cruntime.Mana
|
|||
k8s := cc.KubernetesConfig
|
||||
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "parsing Kubernetes version")
|
||||
return nil, fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
|
||||
// parses a map of the feature gates for kubeadm and component
|
||||
kubeadmFeatureArgs, componentFeatureArgs, err := parseFeatureArgs(k8s.FeatureGates)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "parses feature gate config for kubeadm and component")
|
||||
return nil, fmt.Errorf("parses feature gate config for kubeadm and component: %w", err)
|
||||
}
|
||||
|
||||
// In case of no port assigned, use default
|
||||
|
|
@ -64,17 +63,17 @@ func GenerateKubeadmYAML(cc config.ClusterConfig, n config.Node, r cruntime.Mana
|
|||
if !r.Active() {
|
||||
return nil, cruntime.ErrContainerRuntimeNotRunning
|
||||
}
|
||||
return nil, errors.Wrap(err, "getting cgroup driver")
|
||||
return nil, fmt.Errorf("getting cgroup driver: %w", err)
|
||||
}
|
||||
|
||||
componentOpts, err := createExtraComponentConfig(k8s.ExtraOptions, version, componentFeatureArgs, n)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "generating extra component config for kubeadm")
|
||||
return nil, fmt.Errorf("generating extra component config for kubeadm: %w", err)
|
||||
}
|
||||
|
||||
cnm, err := cni.New(&cc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cni")
|
||||
return nil, fmt.Errorf("cni: %w", err)
|
||||
}
|
||||
|
||||
podCIDR := cnm.CIDR()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"path"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/ktmpl"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
|
|
@ -51,12 +50,12 @@ func extraKubeletOpts(mc config.ClusterConfig, nc config.Node, r cruntime.Manage
|
|||
k8s := mc.KubernetesConfig
|
||||
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "parsing Kubernetes version")
|
||||
return nil, fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
|
||||
extraOpts, err := extraConfigForComponent(Kubelet, k8s.ExtraOptions, version)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "generating extra configuration for kubelet")
|
||||
return nil, fmt.Errorf("generating extra configuration for kubelet: %w", err)
|
||||
}
|
||||
|
||||
for k, v := range r.KubeletOptions() {
|
||||
|
|
@ -110,7 +109,7 @@ func extraKubeletOpts(mc config.ClusterConfig, nc config.Node, r cruntime.Manage
|
|||
// parses a map of the feature gates for kubelet
|
||||
_, kubeletFeatureArgs, err := parseFeatureArgs(k8s.FeatureGates)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "parses feature gate config for kubelet")
|
||||
return nil, fmt.Errorf("parses feature gate config for kubelet: %w", err)
|
||||
}
|
||||
|
||||
if kubeletFeatureArgs != "" {
|
||||
|
|
@ -155,7 +154,7 @@ func NewKubeletService(cfg config.KubernetesConfig) ([]byte, error) {
|
|||
var b bytes.Buffer
|
||||
opts := struct{ KubeletPath string }{KubeletPath: path.Join(binRoot(cfg.KubernetesVersion), "kubelet")}
|
||||
if err := ktmpl.KubeletServiceTemplate.Execute(&b, opts); err != nil {
|
||||
return nil, errors.Wrap(err, "template execute")
|
||||
return nil, fmt.Errorf("template execute: %w", err)
|
||||
}
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
|
@ -136,7 +135,7 @@ func WaitForHealthyAPIServer(r cruntime.Manager, bs bootstrapper.Bootstrapper, c
|
|||
func APIServerVersionMatch(client *kubernetes.Clientset, expected string) error {
|
||||
vi, err := client.ServerVersion()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "server version")
|
||||
return fmt.Errorf("server version: %w", err)
|
||||
}
|
||||
klog.Infof("control plane version: %s", vi)
|
||||
if version.CompareKubeAwareVersionStrings(vi.String(), expected) != 0 {
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ package kverify
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
|
@ -49,7 +49,7 @@ func WaitForDefaultSA(cs *kubernetes.Clientset, timeout time.Duration) error {
|
|||
return false, nil
|
||||
}
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), kconst.APICallRetryInterval, timeout, true, saReady); err != nil {
|
||||
return errors.Wrapf(err, "waited %s for SA", time.Since(start))
|
||||
return fmt.Errorf("waited %s for SA: %w", time.Since(start), err)
|
||||
}
|
||||
|
||||
klog.Infof("duration metric: took %s for default service account to be created ...", time.Since(start))
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
|
@ -115,7 +114,7 @@ func NodePressure(cs *kubernetes.Clientset) error {
|
|||
|
||||
err = retry.Expo(listNodes, kconst.APICallRetryInterval, 2*time.Minute)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list nodes retry")
|
||||
return fmt.Errorf("list nodes retry: %w", err)
|
||||
}
|
||||
|
||||
for _, n := range ns.Items {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
|
@ -121,7 +120,7 @@ func WaitForAppsRunning(cs *kubernetes.Clientset, expected []string, timeout tim
|
|||
}
|
||||
|
||||
if err := retry.Local(checkRunning, timeout); err != nil {
|
||||
return errors.Wrapf(err, "expected k8s-apps")
|
||||
return fmt.Errorf("expected k8s-apps: %w", err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to wait for k8s-apps to be running ...", time.Since(start))
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||
package bsutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
)
|
||||
|
|
@ -29,7 +29,7 @@ import (
|
|||
func AdjustResourceLimits(c command.Runner) error {
|
||||
rr, err := c.RunCmd(exec.Command("/bin/bash", "-c", "cat /proc/$(pgrep kube-apiserver)/oom_adj"))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "oom_adj check cmd %s. ", rr.Command())
|
||||
return fmt.Errorf("oom_adj check cmd %s. : %w", rr.Command(), err)
|
||||
}
|
||||
klog.Infof("apiserver oom_adj: %s", rr.Stdout.String())
|
||||
// oom_adj is already a negative number
|
||||
|
|
@ -41,7 +41,7 @@ func AdjustResourceLimits(c command.Runner) error {
|
|||
// Prevent the apiserver from OOM'ing before other pods, as it is our gateway into the cluster.
|
||||
// It'd be preferable to do this via Kubernetes, but kubeadm doesn't have a way to set pod QoS.
|
||||
if _, err = c.RunCmd(exec.Command("/bin/bash", "-c", "echo -10 | sudo tee /proc/$(pgrep kube-apiserver)/oom_adj")); err != nil {
|
||||
return errors.Wrap(err, "oom_adj adjust")
|
||||
return fmt.Errorf("oom_adj adjust: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/otiai10/copy"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/client-go/tools/clientcmd/api"
|
||||
|
|
@ -69,7 +68,7 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
|
||||
sharedCerts, regen, err := generateSharedCACerts()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generate shared ca certs")
|
||||
return fmt.Errorf("generate shared ca certs: %w", err)
|
||||
}
|
||||
|
||||
xfer := []string{
|
||||
|
|
@ -83,7 +82,7 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
if n.ControlPlane || regen {
|
||||
profileCerts, err := generateProfileCerts(k8s, n, sharedCerts, regen)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generate profile certs")
|
||||
return fmt.Errorf("generate profile certs: %w", err)
|
||||
}
|
||||
xfer = append(xfer, profileCerts...)
|
||||
}
|
||||
|
|
@ -101,14 +100,14 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
// note: src(c) is user os' path, dst is kic/iso (linux) path
|
||||
certFile, err := assets.NewFileAsset(c, vmpath.GuestKubernetesCertsDir, filepath.Base(c), properPerms(c))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "create cert file asset for %s", c)
|
||||
return fmt.Errorf("create cert file asset for %s: %w", c, err)
|
||||
}
|
||||
copyableFiles = append(copyableFiles, certFile)
|
||||
}
|
||||
|
||||
caCerts, err := collectCACerts()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "collect ca certs")
|
||||
return fmt.Errorf("collect ca certs: %w", err)
|
||||
}
|
||||
|
||||
for src, dst := range caCerts {
|
||||
|
|
@ -116,7 +115,7 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
// note: src is user os' path, dst is kic/iso (linux) path
|
||||
certFile, err := assets.NewFileAsset(src, path.Dir(dst), path.Base(dst), "0644")
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "create ca cert file asset for %s", src)
|
||||
return fmt.Errorf("create ca cert file asset for %s: %w", src, err)
|
||||
}
|
||||
copyableFiles = append(copyableFiles, certFile)
|
||||
}
|
||||
|
|
@ -162,11 +161,11 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
kubeCfg := api.NewConfig()
|
||||
err = kubeconfig.PopulateFromSettings(kcs, kubeCfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "populating kubeconfig")
|
||||
return fmt.Errorf("populating kubeconfig: %w", err)
|
||||
}
|
||||
data, err := runtime.Encode(latest.Codec, kubeCfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "encoding kubeconfig")
|
||||
return fmt.Errorf("encoding kubeconfig: %w", err)
|
||||
}
|
||||
kubeCfgFile := assets.NewMemoryAsset(data, vmpath.GuestPersistentDir, "kubeconfig", "0644")
|
||||
copyableFiles = append(copyableFiles, kubeCfgFile)
|
||||
|
|
@ -174,16 +173,16 @@ func SetupCerts(k8s config.ClusterConfig, n config.Node, pcpCmd command.Runner,
|
|||
|
||||
for _, f := range copyableFiles {
|
||||
if err := cmd.Copy(f); err != nil {
|
||||
return errors.Wrapf(err, "Copy %s", f.GetSourcePath())
|
||||
return fmt.Errorf("Copy %s: %w", f.GetSourcePath(), err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := installCertSymlinks(cmd, caCerts); err != nil {
|
||||
return errors.Wrap(err, "install cert symlinks")
|
||||
return fmt.Errorf("install cert symlinks: %w", err)
|
||||
}
|
||||
|
||||
if err := renewExpiredKubeadmCerts(cmd, k8s); err != nil {
|
||||
return errors.Wrap(err, "renew expired kubeadm certs")
|
||||
return fmt.Errorf("renew expired kubeadm certs: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -226,7 +225,7 @@ func generateSharedCACerts() (sharedCACerts, bool, error) {
|
|||
klog.Infof("acquiring lock for ca certs: %+v", spec)
|
||||
releaser, err := lock.Acquire(spec)
|
||||
if err != nil {
|
||||
return cc, false, errors.Wrapf(err, "acquire lock for ca certs %+v", spec)
|
||||
return cc, false, fmt.Errorf("acquire lock for ca certs %+v: %w", spec, err)
|
||||
}
|
||||
defer releaser.Release()
|
||||
|
||||
|
|
@ -239,7 +238,7 @@ func generateSharedCACerts() (sharedCACerts, bool, error) {
|
|||
regenProfileCerts = true
|
||||
klog.Infof("generating %q ca cert: %s", ca.subject, ca.keyPath)
|
||||
if err := util.GenerateCACert(ca.certPath, ca.keyPath, ca.subject); err != nil {
|
||||
return cc, false, errors.Wrapf(err, "generate %q ca cert: %s", ca.subject, ca.keyPath)
|
||||
return cc, false, fmt.Errorf("generate %q ca cert: %s: %w", ca.subject, ca.keyPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +258,7 @@ func generateProfileCerts(cfg config.ClusterConfig, n config.Node, shared shared
|
|||
|
||||
serviceIP, err := util.ServiceClusterIP(k8s.ServiceCIDR)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get service cluster ip")
|
||||
return nil, fmt.Errorf("get service cluster ip: %w", err)
|
||||
}
|
||||
|
||||
apiServerIPs := append([]net.IP{}, k8s.APIServerIPs...)
|
||||
|
|
@ -374,17 +373,17 @@ func generateProfileCerts(cfg config.ClusterConfig, n config.Node, shared shared
|
|||
cfg.CertExpiration,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "generate signed profile cert for %q", spec.subject)
|
||||
return nil, fmt.Errorf("generate signed profile cert for %q: %w", spec.subject, err)
|
||||
}
|
||||
|
||||
if spec.hash != "" {
|
||||
klog.Infof("copying %s -> %s", cp, spec.certPath)
|
||||
if err := copy.Copy(cp, spec.certPath); err != nil {
|
||||
return nil, errors.Wrap(err, "copy profile cert")
|
||||
return nil, fmt.Errorf("copy profile cert: %w", err)
|
||||
}
|
||||
klog.Infof("copying %s -> %s", kp, spec.keyPath)
|
||||
if err := copy.Copy(kp, spec.keyPath); err != nil {
|
||||
return nil, errors.Wrap(err, "copy profile cert key")
|
||||
return nil, fmt.Errorf("copy profile cert key: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -420,7 +419,7 @@ func renewExpiredKubeadmCerts(cmd command.Runner, cc config.ClusterConfig) error
|
|||
out.WarningT("kubeadm certificates have expired. Generating new ones...")
|
||||
bashCmd := fmt.Sprintf("%s certs renew all --config %s", bsutil.KubeadmCmdWithPath(cc.KubernetesConfig.KubernetesVersion), constants.KubeadmYamlPath)
|
||||
if _, err := cmd.RunCmd(exec.Command("sudo", "/bin/bash", "-c", bashCmd)); err != nil {
|
||||
return errors.Wrap(err, "kubeadm certs renew")
|
||||
return fmt.Errorf("kubeadm certs renew: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -497,7 +496,7 @@ func collectCACerts() (map[string]string, error) {
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "collecting CA certs from %s", certsDir)
|
||||
return nil, fmt.Errorf("collecting CA certs from %s: %w", certsDir, err)
|
||||
}
|
||||
|
||||
excluded := []string{"ca.pem", "cert.pem"}
|
||||
|
|
@ -529,7 +528,7 @@ func getSubjectHash(cr command.Runner, filePath string) (string, error) {
|
|||
rr, err := cr.RunCmd(exec.Command("openssl", "x509", "-hash", "-noout", "-in", filePath))
|
||||
if err != nil {
|
||||
crr, _ := cr.RunCmd(exec.Command("cat", filePath))
|
||||
return "", errors.Wrapf(err, "cert:\n%s\n---\n%s", lrr.Output(), crr.Stdout.String())
|
||||
return "", fmt.Errorf("cert:\n%s\n---\n%s: %w", lrr.Output(), crr.Stdout.String(), err)
|
||||
}
|
||||
stringHash := strings.TrimSpace(rr.Stdout.String())
|
||||
return stringHash, nil
|
||||
|
|
@ -553,10 +552,10 @@ func installCertSymlinks(cr command.Runner, caCerts map[string]string) error {
|
|||
certStorePath := path.Join(vmpath.GuestCertStoreDir, dstFilename)
|
||||
// to avoid shell-based command exploitation will run these separately not in one command
|
||||
if _, err := cr.RunCmd(exec.Command("sudo", "test", "-s", caCertFile)); err != nil {
|
||||
return errors.Wrapf(err, "verify ca cert %s", caCertFile)
|
||||
return fmt.Errorf("verify ca cert %s: %w", caCertFile, err)
|
||||
}
|
||||
if _, err := cr.RunCmd(exec.Command("sudo", "ln", "-fs", caCertFile, certStorePath)); err != nil {
|
||||
return errors.Wrapf(err, "create symlink for %s", caCertFile)
|
||||
return fmt.Errorf("create symlink for %s: %w", caCertFile, err)
|
||||
}
|
||||
|
||||
if !hasSSLBinary {
|
||||
|
|
@ -565,7 +564,7 @@ func installCertSymlinks(cr command.Runner, caCerts map[string]string) error {
|
|||
|
||||
subjectHash, err := getSubjectHash(cr, caCertFile)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "calculate hash for cacert %s", caCertFile)
|
||||
return fmt.Errorf("calculate hash for cacert %s: %w", caCertFile, err)
|
||||
}
|
||||
subjectHashLink := path.Join(vmpath.GuestCertStoreDir, fmt.Sprintf("%s.0", subjectHash))
|
||||
|
||||
|
|
@ -575,7 +574,7 @@ func installCertSymlinks(cr command.Runner, caCerts map[string]string) error {
|
|||
continue
|
||||
}
|
||||
if _, err := cr.RunCmd(exec.Command("sudo", "ln", "-fs", certStorePath, subjectHashLink)); err != nil {
|
||||
return errors.Wrapf(err, "create symlink for %s", caCertFile)
|
||||
return fmt.Errorf("create symlink for %s: %w", caCertFile, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -21,14 +21,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Kubeadm returns a list of images necessary to bootstrap kubeadm
|
||||
func Kubeadm(mirror string, version string) ([]string, error) {
|
||||
v, err := semver.Make(strings.TrimPrefix(version, "v"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "semver")
|
||||
return nil, fmt.Errorf("semver: %w", err)
|
||||
}
|
||||
if v.Major > 1 {
|
||||
return nil, fmt.Errorf("version too new: %v", v)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import (
|
|||
// WARNING: Do not use path/filepath in this package unless you want bizarre Windows paths
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
core "k8s.io/api/core/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
|
@ -135,7 +134,7 @@ func (k *Bootstrapper) createCompatSymlinks() error {
|
|||
|
||||
c := exec.Command("sudo", "ln", "-s", legacyEtcd, bsutil.EtcdDataDir())
|
||||
if rr, err := k.c.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "create symlink failed: %s", rr.Command())
|
||||
return fmt.Errorf("create symlink failed: %s: %w", rr.Command(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -175,7 +174,7 @@ func (k *Bootstrapper) clearStaleConfigs(cfg config.ClusterConfig) {
|
|||
func (k *Bootstrapper) init(cfg config.ClusterConfig, options *run.CommandOptions) error {
|
||||
ver, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing Kubernetes version")
|
||||
return fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
|
||||
extraFlags := bsutil.CreateFlagsFromExtraArgs(cfg.KubernetesConfig.ExtraOptions)
|
||||
|
|
@ -245,7 +244,7 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig, options *run.CommandOption
|
|||
wg.Add(1)
|
||||
sc, err := k.c.StartCmd(c)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "start")
|
||||
return fmt.Errorf("start: %w", err)
|
||||
}
|
||||
go outputKubeadmInitSteps(kr, &wg)
|
||||
if _, err := k.c.WaitCmd(sc); err != nil {
|
||||
|
|
@ -256,13 +255,13 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig, options *run.CommandOption
|
|||
if strings.Contains(err.Error(), "'kubeadm': Permission denied") {
|
||||
return ErrNoExecLinux
|
||||
}
|
||||
return errors.Wrap(err, "wait")
|
||||
return fmt.Errorf("wait: %w", err)
|
||||
}
|
||||
kw.Close()
|
||||
wg.Wait()
|
||||
|
||||
if err := k.applyCNI(cfg, true); err != nil {
|
||||
return errors.Wrap(err, "apply cni")
|
||||
return fmt.Errorf("apply cni: %w", err)
|
||||
}
|
||||
|
||||
wg.Add(3)
|
||||
|
|
@ -353,7 +352,7 @@ func (k *Bootstrapper) applyCNI(cfg config.ClusterConfig, registerStep ...bool)
|
|||
|
||||
cnm, err := cni.New(&cfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cni config")
|
||||
return fmt.Errorf("cni config: %w", err)
|
||||
}
|
||||
|
||||
if _, ok := cnm.(cni.Disabled); ok {
|
||||
|
|
@ -369,7 +368,7 @@ func (k *Bootstrapper) applyCNI(cfg config.ClusterConfig, registerStep ...bool)
|
|||
}
|
||||
|
||||
if err := cnm.Apply(k.c); err != nil {
|
||||
return errors.Wrap(err, "cni apply")
|
||||
return fmt.Errorf("cni apply: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -384,7 +383,7 @@ func (k *Bootstrapper) unpause(cfg config.ClusterConfig) error {
|
|||
|
||||
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: []string{"kube-system"}})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list paused")
|
||||
return fmt.Errorf("list paused: %w", err)
|
||||
}
|
||||
|
||||
if len(ids) > 0 {
|
||||
|
|
@ -429,7 +428,7 @@ func (k *Bootstrapper) StartCluster(cfg config.ClusterConfig, options *run.Comma
|
|||
|
||||
conf := constants.KubeadmYamlPath
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "cp", conf+".new", conf)); err != nil {
|
||||
return errors.Wrap(err, "cp")
|
||||
return fmt.Errorf("cp: %w", err)
|
||||
}
|
||||
|
||||
err := k.init(cfg, options)
|
||||
|
|
@ -461,17 +460,17 @@ func (k *Bootstrapper) tunnelToAPIServer(cfg config.ClusterConfig, options *run.
|
|||
|
||||
m, err := machine.NewAPIClient(options)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "create libmachine api client")
|
||||
return fmt.Errorf("create libmachine api client: %w", err)
|
||||
}
|
||||
|
||||
cp, err := config.ControlPlane(cfg)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "get control-plane node")
|
||||
return fmt.Errorf("get control-plane node: %w", err)
|
||||
}
|
||||
|
||||
args := []string{"-f", "-NTL", fmt.Sprintf("%d:localhost:8443", cfg.APIServerPort)}
|
||||
if err = machine.CreateSSHShell(m, cfg, cp, args, false); err != nil {
|
||||
return errors.Wrapf(err, "ssh command")
|
||||
return fmt.Errorf("ssh command: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -484,7 +483,7 @@ func (k *Bootstrapper) client(ip string, port int) (*kubernetes.Clientset, error
|
|||
|
||||
cc, err := kapi.ClientConfig(k.contextName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "client config")
|
||||
return nil, fmt.Errorf("client config: %w", err)
|
||||
}
|
||||
|
||||
endpoint := fmt.Sprintf("https://%s", net.JoinHostPort(ip, strconv.Itoa(port)))
|
||||
|
|
@ -513,16 +512,16 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
|
|||
// TODO: #7706: for better performance we could use k.client inside minikube to avoid asking for external IP:PORT
|
||||
cp, err := config.ControlPlane(cfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get control-plane node")
|
||||
return fmt.Errorf("get control-plane node: %w", err)
|
||||
}
|
||||
hostname, _, port, err := driver.ControlPlaneEndpoint(&cfg, &cp, cfg.Driver)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get control-plane endpoint")
|
||||
return fmt.Errorf("get control-plane endpoint: %w", err)
|
||||
}
|
||||
|
||||
client, err := k.client(hostname, port)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "kubernetes client")
|
||||
return fmt.Errorf("kubernetes client: %w", err)
|
||||
}
|
||||
|
||||
if !kverify.ShouldWait(cfg.VerifyComponents) {
|
||||
|
|
@ -530,7 +529,7 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
|
|||
|
||||
if err := kverify.NodePressure(client); err != nil {
|
||||
adviseNodePressure(err, cfg.Name, cfg.Driver)
|
||||
return errors.Wrap(err, "node pressure")
|
||||
return fmt.Errorf("node pressure: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -539,48 +538,48 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
|
|||
if cfg.VerifyComponents[kverify.NodeReadyKey] || cfg.VerifyComponents[kverify.ExtraKey] {
|
||||
name := bsutil.KubeNodeName(cfg, n)
|
||||
if err := kverify.WaitNodeCondition(client, name, core.NodeReady, timeout); err != nil {
|
||||
return errors.Wrap(err, "waiting for node to be ready")
|
||||
return fmt.Errorf("waiting for node to be ready: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
cr, err := cruntime.New(cruntime.Config{Type: cfg.KubernetesConfig.ContainerRuntime, Runner: k.c})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "create runtme-manager %s", cfg.KubernetesConfig.ContainerRuntime)
|
||||
return fmt.Errorf("create runtme-manager %s: %w", cfg.KubernetesConfig.ContainerRuntime, err)
|
||||
}
|
||||
|
||||
if n.ControlPlane {
|
||||
if cfg.VerifyComponents[kverify.APIServerWaitKey] {
|
||||
if err := kverify.WaitForAPIServerProcess(cr, k, cfg, k.c, start, timeout); err != nil {
|
||||
return errors.Wrap(err, "wait for apiserver proc")
|
||||
return fmt.Errorf("wait for apiserver proc: %w", err)
|
||||
}
|
||||
|
||||
if err := kverify.WaitForHealthyAPIServer(cr, k, cfg, k.c, client, start, hostname, port, timeout); err != nil {
|
||||
return errors.Wrap(err, "wait for healthy API server")
|
||||
return fmt.Errorf("wait for healthy API server: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.VerifyComponents[kverify.SystemPodsWaitKey] {
|
||||
if err := kverify.WaitForSystemPods(cr, k, cfg, k.c, client, start, timeout); err != nil {
|
||||
return errors.Wrap(err, "waiting for system pods")
|
||||
return fmt.Errorf("waiting for system pods: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.VerifyComponents[kverify.DefaultSAWaitKey] {
|
||||
if err := kverify.WaitForDefaultSA(client, timeout); err != nil {
|
||||
return errors.Wrap(err, "waiting for default service account")
|
||||
return fmt.Errorf("waiting for default service account: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.VerifyComponents[kverify.AppsRunningKey] {
|
||||
if err := kverify.WaitForAppsRunning(client, kverify.AppsRunningList, timeout); err != nil {
|
||||
return errors.Wrap(err, "waiting for apps_running")
|
||||
return fmt.Errorf("waiting for apps_running: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.VerifyComponents[kverify.KubeletKey] {
|
||||
if err := kverify.WaitForService(k.c, "kubelet", timeout); err != nil {
|
||||
return errors.Wrap(err, "waiting for kubelet")
|
||||
return fmt.Errorf("waiting for kubelet: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -588,7 +587,7 @@ func (k *Bootstrapper) WaitForNode(cfg config.ClusterConfig, n config.Node, time
|
|||
|
||||
if err := kverify.NodePressure(client); err != nil {
|
||||
adviseNodePressure(err, cfg.Name, cfg.Driver)
|
||||
return errors.Wrap(err, "node pressure")
|
||||
return fmt.Errorf("node pressure: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -608,12 +607,12 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
|
||||
pcp, err := config.ControlPlane(cfg)
|
||||
if err != nil || !config.IsPrimaryControlPlane(cfg, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
return fmt.Errorf("get primary control-plane node: %w", err)
|
||||
}
|
||||
|
||||
host, _, port, err := driver.ControlPlaneEndpoint(&cfg, &pcp, cfg.Driver)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get primary control-plane endpoint")
|
||||
return fmt.Errorf("get primary control-plane endpoint: %w", err)
|
||||
}
|
||||
|
||||
// Save the costly tax of reinstalling Kubernetes if the only issue is a missing kube context
|
||||
|
|
@ -623,7 +622,7 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
|
||||
client, err := k.client(host, port)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting k8s client")
|
||||
return fmt.Errorf("getting k8s client: %w", err)
|
||||
}
|
||||
|
||||
// If the cluster is running, check if we have any work to do.
|
||||
|
|
@ -656,7 +655,7 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
k.clearStaleConfigs(cfg)
|
||||
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "cp", conf+".new", conf)); err != nil {
|
||||
return errors.Wrap(err, "cp")
|
||||
return fmt.Errorf("cp: %w", err)
|
||||
}
|
||||
|
||||
baseCmd := fmt.Sprintf("%s init", bsutil.KubeadmCmdWithPath(cfg.KubernetesConfig.KubernetesVersion))
|
||||
|
|
@ -674,32 +673,32 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
klog.Errorf("%s failed - will try once more: %v", c, err)
|
||||
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "/bin/bash", "-c", c)); err != nil {
|
||||
return errors.Wrap(err, "run")
|
||||
return fmt.Errorf("run: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cr, err := cruntime.New(cruntime.Config{Type: cfg.KubernetesConfig.ContainerRuntime, Runner: k.c})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "runtime")
|
||||
return fmt.Errorf("runtime: %w", err)
|
||||
}
|
||||
|
||||
// We must ensure that the apiserver is healthy before proceeding
|
||||
if err := kverify.WaitForAPIServerProcess(cr, k, cfg, k.c, time.Now(), kconst.DefaultControlPlaneTimeout); err != nil {
|
||||
return errors.Wrap(err, "apiserver healthz")
|
||||
return fmt.Errorf("apiserver healthz: %w", err)
|
||||
}
|
||||
|
||||
if err := kverify.WaitForHealthyAPIServer(cr, k, cfg, k.c, client, time.Now(), host, port, kconst.DefaultControlPlaneTimeout); err != nil {
|
||||
return errors.Wrap(err, "apiserver health")
|
||||
return fmt.Errorf("apiserver health: %w", err)
|
||||
}
|
||||
|
||||
// because reboots clear /etc/cni
|
||||
if err := k.applyCNI(cfg); err != nil {
|
||||
return errors.Wrap(err, "apply cni")
|
||||
return fmt.Errorf("apply cni: %w", err)
|
||||
}
|
||||
|
||||
if err := kverify.WaitForSystemPods(cr, k, cfg, k.c, client, time.Now(), kconst.DefaultControlPlaneTimeout); err != nil {
|
||||
return errors.Wrap(err, "system pods")
|
||||
return fmt.Errorf("system pods: %w", err)
|
||||
}
|
||||
|
||||
if err := kverify.NodePressure(client); err != nil {
|
||||
|
|
@ -717,7 +716,7 @@ func (k *Bootstrapper) restartPrimaryControlPlane(cfg config.ClusterConfig) erro
|
|||
}
|
||||
if err = retry.Expo(addonPhase, 100*time.Microsecond, 30*time.Second); err != nil {
|
||||
klog.Warningf("addon install failed, wil retry: %v", err)
|
||||
return errors.Wrap(err, "addons")
|
||||
return fmt.Errorf("addons: %w", err)
|
||||
}
|
||||
|
||||
// must be called after applyCNI and `kubeadm phase addon all` (ie, coredns redeploy)
|
||||
|
|
@ -769,11 +768,11 @@ func (k *Bootstrapper) JoinCluster(cc config.ClusterConfig, n config.Node, joinC
|
|||
}
|
||||
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "/bin/bash", "-c", joinCmd)); err != nil {
|
||||
return errors.Wrapf(err, "kubeadm join")
|
||||
return fmt.Errorf("kubeadm join: %w", err)
|
||||
}
|
||||
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "/bin/bash", "-c", "systemctl daemon-reload && systemctl enable kubelet && systemctl start kubelet")); err != nil {
|
||||
return errors.Wrap(err, "starting kubelet")
|
||||
return fmt.Errorf("starting kubelet: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -785,7 +784,7 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
|
|||
tokenCmd := exec.Command("sudo", "/bin/bash", "-c", fmt.Sprintf("%s token create --print-join-command --ttl=0", bsutil.KubeadmCmdWithPath(cc.KubernetesConfig.KubernetesVersion)))
|
||||
r, err := k.c.RunCmd(tokenCmd)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "generating join command")
|
||||
return "", fmt.Errorf("generating join command: %w", err)
|
||||
}
|
||||
|
||||
joinCmd := r.Stdout.String()
|
||||
|
|
@ -795,7 +794,7 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
|
|||
// avoid "Found multiple CRI endpoints on the host. Please define which one do you wish to use by setting the 'criSocket' field in the kubeadm configuration file: unix:///var/run/containerd/containerd.sock, unix:///var/run/cri-dockerd.sock" error
|
||||
ver, err := util.ParseKubernetesVersion(cc.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "parsing Kubernetes version")
|
||||
return "", fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
cr, err := cruntime.New(cruntime.Config{Type: cc.KubernetesConfig.ContainerRuntime, Runner: k.c, Socket: cc.KubernetesConfig.CRISocket, KubernetesVersion: ver})
|
||||
if err != nil {
|
||||
|
|
@ -851,11 +850,11 @@ func StopKubernetes(runner command.Runner, cr cruntime.Manager) {
|
|||
func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
|
||||
ver, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing Kubernetes version")
|
||||
return fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
cr, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: k.c, Socket: k8s.CRISocket, KubernetesVersion: ver})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "runtime")
|
||||
return fmt.Errorf("runtime: %w", err)
|
||||
}
|
||||
|
||||
ka := bsutil.KubeadmCmdWithPath(k8s.KubernetesVersion)
|
||||
|
|
@ -885,12 +884,12 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
|||
|
||||
imgs, err := images.Kubeadm(cfg.KubernetesConfig.ImageRepository, cfg.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "kubeadm images")
|
||||
return fmt.Errorf("kubeadm images: %w", err)
|
||||
}
|
||||
|
||||
ver, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing Kubernetes version")
|
||||
return fmt.Errorf("parsing Kubernetes version: %w", err)
|
||||
}
|
||||
r, err := cruntime.New(cruntime.Config{
|
||||
Type: cfg.KubernetesConfig.ContainerRuntime,
|
||||
|
|
@ -899,7 +898,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
|||
KubernetesVersion: ver,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "runtime")
|
||||
return fmt.Errorf("runtime: %w", err)
|
||||
}
|
||||
|
||||
if err := r.Preload(cfg); err != nil {
|
||||
|
|
@ -919,12 +918,12 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
|||
|
||||
pcp, err := config.ControlPlane(cfg)
|
||||
if err != nil || !config.IsPrimaryControlPlane(cfg, pcp) {
|
||||
return errors.Wrap(err, "get primary control-plane node")
|
||||
return fmt.Errorf("get primary control-plane node: %w", err)
|
||||
}
|
||||
|
||||
err = k.UpdateNode(cfg, pcp, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "update primary control-plane node")
|
||||
return fmt.Errorf("update primary control-plane node: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -936,12 +935,12 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
|
||||
kubeletCfg, err := bsutil.NewKubeletConfig(cfg, n, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generating kubelet config")
|
||||
return fmt.Errorf("generating kubelet config: %w", err)
|
||||
}
|
||||
|
||||
kubeletService, err := bsutil.NewKubeletService(cfg.KubernetesConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generating kubelet service")
|
||||
return fmt.Errorf("generating kubelet service: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("kubelet %s config:\n%+v", kubeletCfg, cfg.KubernetesConfig)
|
||||
|
|
@ -958,7 +957,7 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
if config.IsPrimaryControlPlane(cfg, n) {
|
||||
kubeadmCfg, err = bsutil.GenerateKubeadmYAML(cfg, n, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generating kubeadm cfg")
|
||||
return fmt.Errorf("generating kubeadm cfg: %w", err)
|
||||
}
|
||||
files = append(files, assets.NewMemoryAssetTarget(kubeadmCfg, constants.KubeadmYamlPath+".new", "0640"))
|
||||
}
|
||||
|
|
@ -969,7 +968,7 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
// TODO (prezha): remove when fixed upstream - ref: https://github.com/kube-vip/kube-vip/issues/684#issuecomment-1864855405
|
||||
kv, err := semver.ParseTolerant(cfg.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing kubernetes version %q", cfg.KubernetesConfig.KubernetesVersion)
|
||||
return fmt.Errorf("parsing kubernetes version %q: %w", cfg.KubernetesConfig.KubernetesVersion, err)
|
||||
}
|
||||
workaround := kv.GTE(semver.Version{Major: 1, Minor: 29}) && config.IsPrimaryControlPlane(cfg, n) && len(config.ControlPlanes(cfg)) == 1
|
||||
kubevipCfg, err := kubevip.Configure(cfg, k.c, kubeadmCfg, workaround)
|
||||
|
|
@ -984,23 +983,23 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
sm := sysinit.New(k.c)
|
||||
|
||||
if err := bsutil.TransferBinaries(cfg.KubernetesConfig, k.c, sm, cfg.BinaryMirror); err != nil {
|
||||
return errors.Wrap(err, "downloading binaries")
|
||||
return fmt.Errorf("downloading binaries: %w", err)
|
||||
}
|
||||
|
||||
// Installs compatibility shims for non-systemd environments
|
||||
kubeletPath := path.Join(vmpath.GuestPersistentDir, "binaries", cfg.KubernetesConfig.KubernetesVersion, "kubelet")
|
||||
shims, err := sm.GenerateInitShim("kubelet", kubeletPath, bsutil.KubeletSystemdConfFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "shim")
|
||||
return fmt.Errorf("shim: %w", err)
|
||||
}
|
||||
files = append(files, shims...)
|
||||
|
||||
if err := bsutil.CopyFiles(k.c, files); err != nil {
|
||||
return errors.Wrap(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
|
||||
if err := k.copyResolvConf(cfg); err != nil {
|
||||
return errors.Wrap(err, "resolv.conf")
|
||||
return fmt.Errorf("resolv.conf: %w", err)
|
||||
}
|
||||
|
||||
// add "control-plane.minikube.internal" dns alias
|
||||
|
|
@ -1009,12 +1008,12 @@ func (k *Bootstrapper) UpdateNode(cfg config.ClusterConfig, n config.Node, r cru
|
|||
if !config.IsHA(cfg) {
|
||||
cp, err := config.ControlPlane(cfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get control-plane node")
|
||||
return fmt.Errorf("get control-plane node: %w", err)
|
||||
}
|
||||
cpIP = cp.IP
|
||||
}
|
||||
if err := machine.AddHostAlias(k.c, constants.ControlPlaneAlias, net.ParseIP(cpIP)); err != nil {
|
||||
return errors.Wrap(err, "add control-plane alias")
|
||||
return fmt.Errorf("add control-plane alias: %w", err)
|
||||
}
|
||||
|
||||
// "ensure" kubelet is started, intentionally non-fatal in case of an error
|
||||
|
|
@ -1033,10 +1032,10 @@ func (k *Bootstrapper) copyResolvConf(cfg config.ClusterConfig) error {
|
|||
return nil
|
||||
}
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "cp", "/etc/resolv.conf", "/etc/kubelet-resolv.conf")); err != nil {
|
||||
return errors.Wrap(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
if _, err := k.c.RunCmd(exec.Command("sudo", "sed", "-i", "-e", "s/^search .$//", "/etc/kubelet-resolv.conf")); err != nil {
|
||||
return errors.Wrap(err, "sed")
|
||||
return fmt.Errorf("sed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -1085,9 +1084,9 @@ func (k *Bootstrapper) labelAndUntaintNode(cfg config.ClusterConfig, n config.No
|
|||
"label", "--overwrite", "nodes", nodeName, createdAtLbl, verLbl, commitLbl, profileNameLbl, primaryLbl)
|
||||
if _, err := k.c.RunCmd(cmd); err != nil {
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
return errors.Wrapf(err, "timeout apply node labels")
|
||||
return fmt.Errorf("timeout apply node labels: %w", err)
|
||||
}
|
||||
return errors.Wrapf(err, "apply node labels")
|
||||
return fmt.Errorf("apply node labels: %w", err)
|
||||
}
|
||||
|
||||
// primary control-plane and worker nodes should be untainted by default
|
||||
|
|
@ -1098,9 +1097,9 @@ func (k *Bootstrapper) labelAndUntaintNode(cfg config.ClusterConfig, n config.No
|
|||
"taint", "nodes", config.MachineName(cfg, n), "node-role.kubernetes.io/control-plane:NoSchedule-")
|
||||
if _, err := k.c.RunCmd(cmd); err != nil {
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
return errors.Wrapf(err, "timeout remove node taints")
|
||||
return fmt.Errorf("timeout remove node taints: %w", err)
|
||||
}
|
||||
return errors.Wrapf(err, "remove node taints")
|
||||
return fmt.Errorf("remove node taints: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1125,13 +1124,13 @@ func (k *Bootstrapper) elevateKubeSystemPrivileges(cfg config.ClusterConfig) err
|
|||
rr, err := k.c.RunCmd(cmd)
|
||||
if err != nil {
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
return errors.Wrapf(err, "timeout apply sa")
|
||||
return fmt.Errorf("timeout apply sa: %w", err)
|
||||
}
|
||||
// Error from server (AlreadyExists): clusterrolebindings.rbac.authorization.k8s.io "minikube-rbac" already exists
|
||||
if strings.Contains(rr.Output(), "Error from server (AlreadyExists)") {
|
||||
klog.Infof("rbac %q already exists not need to re-create.", rbacName)
|
||||
} else {
|
||||
return errors.Wrapf(err, "apply sa")
|
||||
return fmt.Errorf("apply sa: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1150,7 +1149,7 @@ func (k *Bootstrapper) elevateKubeSystemPrivileges(cfg config.ClusterConfig) err
|
|||
|
||||
// retry up to make sure SA is created
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), kconst.APICallRetryInterval, time.Minute, true, checkSA); err != nil {
|
||||
return errors.Wrap(err, "ensure sa was created")
|
||||
return fmt.Errorf("ensure sa was created: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -1161,17 +1160,17 @@ func (k *Bootstrapper) stopKubeSystem(cfg config.ClusterConfig) error {
|
|||
klog.Info("stopping kube-system containers ...")
|
||||
cr, err := cruntime.New(cruntime.Config{Type: cfg.KubernetesConfig.ContainerRuntime, Socket: cfg.KubernetesConfig.CRISocket, Runner: k.c})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "new cruntime")
|
||||
return fmt.Errorf("new cruntime: %w", err)
|
||||
}
|
||||
|
||||
ids, err := cr.ListContainers(cruntime.ListContainersOptions{Namespaces: []string{"kube-system"}})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list")
|
||||
return fmt.Errorf("list: %w", err)
|
||||
}
|
||||
|
||||
if len(ids) > 0 {
|
||||
if err := cr.StopContainers(ids); err != nil {
|
||||
return errors.Wrap(err, "stop")
|
||||
return fmt.Errorf("stop: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package cluster
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine"
|
||||
"k8s.io/minikube/pkg/libmachine/ssh"
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ func Bootstrapper(api libmachine.API, bootstrapperName string, cc config.Cluster
|
|||
case bootstrapper.Kubeadm:
|
||||
b, err = kubeadm.NewBootstrapper(api, cc, r)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting a new kubeadm bootstrapper")
|
||||
return nil, fmt.Errorf("getting a new kubeadm bootstrapper: %w", err)
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown bootstrapper: %s", bootstrapperName)
|
||||
|
|
@ -58,15 +57,15 @@ func Bootstrapper(api libmachine.API, bootstrapperName string, cc config.Cluster
|
|||
func ControlPlaneBootstrapper(mAPI libmachine.API, cc *config.ClusterConfig, bootstrapperName string) (bootstrapper.Bootstrapper, error) {
|
||||
cp, err := config.ControlPlane(*cc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get primary control-plane node")
|
||||
return nil, fmt.Errorf("get primary control-plane node: %w", err)
|
||||
}
|
||||
h, err := machine.LoadHost(mAPI, config.MachineName(*cc, cp))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load primary control-plane host")
|
||||
return nil, fmt.Errorf("load primary control-plane host: %w", err)
|
||||
}
|
||||
cpr, err := machine.CommandRunner(h)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get primary control-plane command runner")
|
||||
return nil, fmt.Errorf("get primary control-plane command runner: %w", err)
|
||||
}
|
||||
|
||||
bs, err := Bootstrapper(mAPI, bootstrapperName, *cc, cpr)
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ package kubevip
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -131,7 +131,7 @@ func Configure(cc config.ClusterConfig, r command.Runner, kubeadmCfg []byte, wor
|
|||
|
||||
b := bytes.Buffer{}
|
||||
if err := kubeVipTemplate.Execute(&b, params); err != nil {
|
||||
return nil, errors.Wrapf(err, "parse template")
|
||||
return nil, fmt.Errorf("parse template: %w", err)
|
||||
}
|
||||
|
||||
klog.Infof("kube-vip config:\n%s", b.String())
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/libmachine"
|
||||
|
|
@ -43,25 +44,25 @@ func HostIP(hostInfo *host.Host, clusterName string) (net.IP, error) {
|
|||
case driver.SSH:
|
||||
ip, err := hostInfo.Driver.GetIP()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address")
|
||||
return []byte{}, fmt.Errorf("Error getting VM/Host IP address: %w", err)
|
||||
}
|
||||
return net.ParseIP(ip), nil
|
||||
case driver.KVM2:
|
||||
// `host.Driver.GetIP` returns dhcp lease info for a given network(=`virsh net-dhcp-leases minikube-net`)
|
||||
vmIPString, err := hostInfo.Driver.GetIP()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address")
|
||||
return []byte{}, fmt.Errorf("Error getting VM/Host IP address: %w", err)
|
||||
}
|
||||
vmIP := net.ParseIP(vmIPString).To4()
|
||||
if vmIP == nil {
|
||||
// We need the network ip address for minikube-net. It's the start address of the returned subnet.
|
||||
return []byte{}, errors.Wrap(err, "Error converting VM/Host IP address to IPv4 address")
|
||||
return []byte{}, fmt.Errorf("Error converting VM/Host IP address to IPv4 address: %w", err)
|
||||
}
|
||||
return net.IPv4(vmIP[0], vmIP[1], vmIP[2], byte(1)), nil
|
||||
case driver.QEMU, driver.QEMU2:
|
||||
ipString, err := hostInfo.Driver.GetIP()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error getting IP address")
|
||||
return []byte{}, fmt.Errorf("Error getting IP address: %w", err)
|
||||
}
|
||||
if ipString == "127.0.0.1" {
|
||||
// user network case
|
||||
|
|
@ -85,7 +86,7 @@ func HostIP(hostInfo *host.Host, clusterName string) (net.IP, error) {
|
|||
}
|
||||
ip, err := getIPForInterface(fmt.Sprintf("vEthernet (%s)", hypervVirtualSwitch))
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, fmt.Sprintf("ip for interface (%s)", hypervVirtualSwitch))
|
||||
return []byte{}, fmt.Errorf("%s: %w", fmt.Sprintf("ip for interface (%s)", hypervVirtualSwitch), err)
|
||||
}
|
||||
|
||||
return ip, nil
|
||||
|
|
@ -93,13 +94,13 @@ func HostIP(hostInfo *host.Host, clusterName string) (net.IP, error) {
|
|||
vBoxManageCmd := driver.VBoxManagePath()
|
||||
out, err := exec.Command(vBoxManageCmd, "showvminfo", hostInfo.Name, "--machinereadable").Output()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "vboxmanage")
|
||||
return []byte{}, fmt.Errorf("vboxmanage: %w", err)
|
||||
}
|
||||
re := regexp.MustCompile(`hostonlyadapter2="(.*?)"`)
|
||||
iface := re.FindStringSubmatch(string(out))[1]
|
||||
ipList, err := exec.Command(vBoxManageCmd, "list", "hostonlyifs").Output()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address")
|
||||
return []byte{}, fmt.Errorf("Error getting VM/Host IP address: %w", err)
|
||||
}
|
||||
re = regexp.MustCompile(`(?sm)Name:\s*` + iface + `\s*$.+?IPAddress:\s*(\S+)`)
|
||||
ip := re.FindStringSubmatch(string(ipList))[1]
|
||||
|
|
@ -115,12 +116,12 @@ func HostIP(hostInfo *host.Host, clusterName string) (net.IP, error) {
|
|||
}
|
||||
out, err := exec.Command(binPath, "net", "info", "Shared").Output()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error reading the info of Parallels Shared network interface")
|
||||
return []byte{}, fmt.Errorf("Error reading the info of Parallels Shared network interface: %w", err)
|
||||
}
|
||||
re := regexp.MustCompile(`IPv4 address: (.*)`)
|
||||
ipMatch := re.FindStringSubmatch(string(out))
|
||||
if len(ipMatch) < 2 {
|
||||
return []byte{}, errors.Wrap(err, "Error getting the IP address of Parallels Shared network interface")
|
||||
return []byte{}, fmt.Errorf("Error getting the IP address of Parallels Shared network interface: %w", err)
|
||||
}
|
||||
ip := ipMatch[1]
|
||||
|
||||
|
|
@ -132,11 +133,11 @@ func HostIP(hostInfo *host.Host, clusterName string) (net.IP, error) {
|
|||
case driver.VMware:
|
||||
vmIPString, err := hostInfo.Driver.GetIP()
|
||||
if err != nil {
|
||||
return []byte{}, errors.Wrap(err, "Error getting VM IP address")
|
||||
return []byte{}, fmt.Errorf("Error getting VM IP address: %w", err)
|
||||
}
|
||||
vmIP := net.ParseIP(vmIPString).To4()
|
||||
if vmIP == nil {
|
||||
return []byte{}, errors.Wrap(err, "Error converting VM IP address to IPv4 address")
|
||||
return []byte{}, fmt.Errorf("Error converting VM IP address to IPv4 address: %w", err)
|
||||
}
|
||||
return net.IPv4(vmIP[0], vmIP[1], vmIP[2], byte(1)), nil
|
||||
case driver.VFKit, driver.Krunkit:
|
||||
|
|
@ -163,7 +164,7 @@ func DriverIP(api libmachine.API, machineName string) (net.IP, error) {
|
|||
|
||||
ipStr, err := hostInfo.Driver.GetIP()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting IP")
|
||||
return nil, fmt.Errorf("getting IP: %w", err)
|
||||
}
|
||||
if driver.IsKIC(hostInfo.DriverName) {
|
||||
ipStr = oci.DefaultBindIPV4
|
||||
|
|
@ -209,7 +210,7 @@ func getIPForInterface(name string) (net.IP, error) {
|
|||
|
||||
// We found nothing, fail out
|
||||
if i.Name == "" {
|
||||
return nil, errors.Errorf("Could not find interface %s inside %+v", name, ints)
|
||||
return nil, fmt.Errorf("Could not find interface %s inside %+v", name, ints)
|
||||
}
|
||||
|
||||
klog.Infof("Found interface: %+v\n", i)
|
||||
|
|
@ -222,5 +223,5 @@ func getIPForInterface(name string) (net.IP, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return nil, errors.Errorf("Unable to find a IPv4 address for interface %q", name)
|
||||
return nil, fmt.Errorf("Unable to find a IPv4 address for interface %q", name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
|
|
@ -82,11 +81,11 @@ func (m *MountError) Error() string {
|
|||
// Mount runs the mount command from the 9p client on the VM to the 9p server on the host
|
||||
func Mount(r mountRunner, source string, target string, c *MountConfig, pid int) error {
|
||||
if err := Unmount(r, target); err != nil {
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: errors.Wrap(err, "umount")}
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: fmt.Errorf("umount: %w", err)}
|
||||
}
|
||||
|
||||
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -p %s", target))); err != nil {
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: errors.Wrap(err, "create folder pre-mount")}
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: fmt.Errorf("create folder pre-mount: %w", err)}
|
||||
}
|
||||
|
||||
rr, err := r.RunCmd(exec.Command("/bin/bash", "-c", mntCmd(source, target, c)))
|
||||
|
|
@ -94,7 +93,7 @@ func Mount(r mountRunner, source string, target string, c *MountConfig, pid int)
|
|||
if strings.Contains(rr.Stderr.String(), "Connection timed out") {
|
||||
return &MountError{ErrorType: MountErrorConnect, UnderlyingError: err}
|
||||
}
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: errors.Wrapf(err, "mount with cmd %s ", rr.Command())}
|
||||
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: fmt.Errorf("mount with cmd %s : %w", rr.Command(), err)}
|
||||
}
|
||||
|
||||
profile := viper.GetString("profile")
|
||||
|
|
@ -175,7 +174,7 @@ func Unmount(r mountRunner, target string) error {
|
|||
// grep because findmnt will also display the parent!
|
||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("[ \"x$(findmnt -T %s | grep %s)\" != \"x\" ] && sudo umount -f -l %s || echo ", target, target, target))
|
||||
if _, err := r.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "unmount")
|
||||
return fmt.Errorf("unmount: %w", err)
|
||||
}
|
||||
klog.Infof("unmount for %s ran successfully", target)
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||
package cluster
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||
|
|
@ -52,12 +52,12 @@ func pause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string
|
|||
klog.Info("kubelet running: ", sm.Active("kubelet"))
|
||||
|
||||
if err := sm.DisableNow("kubelet"); err != nil {
|
||||
return ids, errors.Wrap(err, "kubelet disable --now")
|
||||
return ids, fmt.Errorf("kubelet disable --now: %w", err)
|
||||
}
|
||||
|
||||
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Running, Namespaces: namespaces})
|
||||
if err != nil {
|
||||
return ids, errors.Wrap(err, "list running")
|
||||
return ids, fmt.Errorf("list running: %w", err)
|
||||
}
|
||||
|
||||
if len(ids) == 0 {
|
||||
|
|
@ -66,7 +66,7 @@ func pause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string
|
|||
}
|
||||
|
||||
if err := cr.PauseContainers(ids); err != nil {
|
||||
return ids, errors.Wrap(err, "pausing containers")
|
||||
return ids, fmt.Errorf("pausing containers: %w", err)
|
||||
}
|
||||
|
||||
if doesNamespaceContainKubeSystem(namespaces) {
|
||||
|
|
@ -94,19 +94,19 @@ func Unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]stri
|
|||
func unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string, error) {
|
||||
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: namespaces})
|
||||
if err != nil {
|
||||
return ids, errors.Wrap(err, "list paused")
|
||||
return ids, fmt.Errorf("list paused: %w", err)
|
||||
}
|
||||
|
||||
if len(ids) == 0 {
|
||||
klog.Warningf("no paused containers found")
|
||||
} else if err := cr.UnpauseContainers(ids); err != nil {
|
||||
return ids, errors.Wrap(err, "unpause")
|
||||
return ids, fmt.Errorf("unpause: %w", err)
|
||||
}
|
||||
|
||||
sm := sysinit.New(r)
|
||||
|
||||
if err := sm.Start("kubelet"); err != nil {
|
||||
return ids, errors.Wrap(err, "kubelet start")
|
||||
return ids, fmt.Errorf("kubelet start: %w", err)
|
||||
}
|
||||
|
||||
if doesNamespaceContainKubeSystem(namespaces) {
|
||||
|
|
@ -120,7 +120,7 @@ func unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]stri
|
|||
func CheckIfPaused(cr cruntime.Manager, namespaces []string) (bool, error) {
|
||||
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: namespaces})
|
||||
if err != nil {
|
||||
return true, errors.Wrap(err, "list paused")
|
||||
return true, fmt.Errorf("list paused: %w", err)
|
||||
}
|
||||
|
||||
if len(ids) > 0 {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"time"
|
||||
|
||||
cloudevents "github.com/cloudevents/sdk-go/v2"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/libmachine"
|
||||
"k8s.io/minikube/pkg/libmachine/state"
|
||||
|
||||
|
|
@ -370,7 +369,7 @@ func NodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St
|
|||
hs, err := machine.Status(api, name)
|
||||
klog.Infof("%s host status = %q (err=%v)", name, hs, err)
|
||||
if err != nil {
|
||||
return st, errors.Wrap(err, "host")
|
||||
return st, fmt.Errorf("host: %w", err)
|
||||
}
|
||||
|
||||
// We have no record of this host. Return nonexistent struct
|
||||
|
|
@ -478,12 +477,12 @@ func readEventLog(name string) ([]cloudevents.Event, time.Time, error) {
|
|||
|
||||
st, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, time.Time{}, errors.Wrap(err, "stat")
|
||||
return nil, time.Time{}, fmt.Errorf("stat: %w", err)
|
||||
}
|
||||
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, st.ModTime(), errors.Wrap(err, "open")
|
||||
return nil, st.ModTime(), fmt.Errorf("open: %w", err)
|
||||
}
|
||||
var events []cloudevents.Event
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"os/exec"
|
||||
"text/template"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
)
|
||||
|
|
@ -98,11 +97,11 @@ func (c Bridge) Apply(r Runner) error {
|
|||
|
||||
f, err := c.netconf()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "netconf")
|
||||
return fmt.Errorf("netconf: %w", err)
|
||||
}
|
||||
|
||||
if err := r.Copy(f); err != nil {
|
||||
return errors.Wrapf(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -84,7 +83,7 @@ func (c Calico) manifest() (assets.CopyableFile, error) {
|
|||
func (c Calico) Apply(r Runner) error {
|
||||
m, err := c.manifest()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "manifest")
|
||||
return fmt.Errorf("manifest: %w", err)
|
||||
}
|
||||
return applyManifest(c.cc, r, m)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/icza/dyno"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v2"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -89,12 +88,12 @@ func (c Cilium) GenerateCiliumYAML() ([]byte, error) {
|
|||
func (c Cilium) Apply(r Runner) error {
|
||||
// see https://kubernetes.io/docs/tasks/administer-cluster/network-policy-provider/cilium-network-policy/
|
||||
if _, err := r.RunCmd(exec.Command("sudo", "/bin/bash", "-c", "grep 'bpffs /sys/fs/bpf' /proc/mounts || sudo mount bpffs -t bpf /sys/fs/bpf")); err != nil {
|
||||
return errors.Wrap(err, "bpf mount")
|
||||
return fmt.Errorf("bpf mount: %w", err)
|
||||
}
|
||||
|
||||
ciliumCfg, err := c.GenerateCiliumYAML()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "generating cilium cfg")
|
||||
return fmt.Errorf("generating cilium cfg: %w", err)
|
||||
}
|
||||
|
||||
return applyManifest(c.cc, r, manifestAsset(ciliumCfg))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/kapi"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
|
|
@ -182,12 +181,12 @@ func applyManifest(cc config.ClusterConfig, r Runner, f assets.CopyableFile) err
|
|||
klog.Infof("applying CNI manifest using %s ...", kubectl)
|
||||
|
||||
if err := r.Copy(f); err != nil {
|
||||
return errors.Wrapf(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "sudo", kubectl, "apply", fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")), "-f", manifestPath())
|
||||
if rr, err := r.RunCmd(cmd); err != nil {
|
||||
return errors.Wrapf(err, "cmd: %s output: %s", rr.Command(), rr.Output())
|
||||
return fmt.Errorf("cmd: %s output: %s: %w", rr.Command(), rr.Output(), err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||
package cni
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -41,7 +41,7 @@ func (c Custom) String() string {
|
|||
func NewCustom(cc config.ClusterConfig, manifest string) (Custom, error) {
|
||||
_, err := os.Stat(manifest)
|
||||
if err != nil {
|
||||
return Custom{}, errors.Wrap(err, "stat")
|
||||
return Custom{}, fmt.Errorf("stat: %w", err)
|
||||
}
|
||||
|
||||
return Custom{
|
||||
|
|
@ -54,7 +54,7 @@ func NewCustom(cc config.ClusterConfig, manifest string) (Custom, error) {
|
|||
func (c Custom) Apply(r Runner) error {
|
||||
m, err := assets.NewFileAsset(c.manifest, path.Dir(manifestPath()), path.Base(manifestPath()), "0644")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "manifest")
|
||||
return fmt.Errorf("manifest: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := m.Close(); err != nil {
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ package cni
|
|||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"text/template"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
)
|
||||
|
|
@ -54,12 +54,12 @@ func (c Flannel) Apply(r Runner) error {
|
|||
// Mostly applicable to the 'none' driver
|
||||
_, err := r.RunCmd(exec.Command("stat", "/opt/cni/bin/portmap"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "required 'portmap' CNI plug-in not found")
|
||||
return fmt.Errorf("required 'portmap' CNI plug-in not found: %w", err)
|
||||
}
|
||||
|
||||
m, err := c.manifest()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "manifest")
|
||||
return fmt.Errorf("manifest: %w", err)
|
||||
}
|
||||
return applyManifest(c.cc, r, m)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ package cni
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"text/template"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
|
|
@ -190,12 +190,12 @@ func (c KindNet) manifest() (assets.CopyableFile, error) {
|
|||
func (c KindNet) Apply(r Runner) error {
|
||||
// This is mostly applicable to the 'none' driver
|
||||
if _, err := r.RunCmd(exec.Command("stat", "/opt/cni/bin/portmap")); err != nil {
|
||||
return errors.Wrap(err, "required 'portmap' CNI plug-in not found")
|
||||
return fmt.Errorf("required 'portmap' CNI plug-in not found: %w", err)
|
||||
}
|
||||
|
||||
m, err := c.manifest()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "manifest")
|
||||
return fmt.Errorf("manifest: %w", err)
|
||||
}
|
||||
return applyManifest(c.cc, r, m)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
)
|
||||
|
||||
|
|
@ -196,14 +197,14 @@ func fileExists(r Runner, f assets.CopyableFile, dst string) (bool, error) {
|
|||
func writeFile(dst string, f assets.CopyableFile, perms os.FileMode) error {
|
||||
w, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE, perms)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create")
|
||||
return fmt.Errorf("create: %w", err)
|
||||
}
|
||||
defer w.Close()
|
||||
|
||||
r := f.(io.Reader)
|
||||
n, err := io.Copy(w, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "copy")
|
||||
return fmt.Errorf("copy: %w", err)
|
||||
}
|
||||
|
||||
if n != int64(f.GetLength()) {
|
||||
|
|
@ -211,7 +212,7 @@ func writeFile(dst string, f assets.CopyableFile, perms os.FileMode) error {
|
|||
}
|
||||
|
||||
if err := w.Chmod(perms); err != nil {
|
||||
return errors.Wrap(err, "chmod")
|
||||
return fmt.Errorf("chmod: %w", err)
|
||||
}
|
||||
|
||||
return w.Close()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
)
|
||||
|
|
@ -115,7 +114,7 @@ func (*execRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error) {
|
|||
cmd.Stderr = errb
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return sc, errors.Wrap(err, "start")
|
||||
return sc, fmt.Errorf("start: %w", err)
|
||||
}
|
||||
|
||||
return sc, nil
|
||||
|
|
@ -143,7 +142,7 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
|
|||
if _, err := os.Stat(dst); err == nil {
|
||||
klog.Infof("found %s, removing ...", dst)
|
||||
if err := e.Remove(f); err != nil {
|
||||
return errors.Wrapf(err, "error removing file %s", dst)
|
||||
return fmt.Errorf("error removing file %s: %w", dst, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,24 +154,24 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
perms, err := strconv.ParseInt(f.GetPermissions(), 8, 0)
|
||||
if err != nil || perms > 07777 {
|
||||
return errors.Wrapf(err, "error converting permissions %s to integer", f.GetPermissions())
|
||||
return fmt.Errorf("error converting permissions %s to integer: %w", f.GetPermissions(), err)
|
||||
}
|
||||
|
||||
if e.sudo {
|
||||
// write to temp location ...
|
||||
tmpfile, err := os.CreateTemp("", "minikube")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating tempfile")
|
||||
return fmt.Errorf("error creating tempfile: %w", err)
|
||||
}
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
if err := writeFile(tmpfile.Name(), f, os.FileMode(perms)); err != nil {
|
||||
return errors.Wrapf(err, "error writing to tempfile %s", tmpfile.Name())
|
||||
return fmt.Errorf("error writing to tempfile %s: %w", tmpfile.Name(), err)
|
||||
}
|
||||
|
||||
// ... then use sudo to move to target
|
||||
if _, err := e.RunCmd(exec.Command("sudo", "cp", "-a", tmpfile.Name(), dst)); err != nil {
|
||||
return errors.Wrapf(err, "error copying tempfile %s to dst %s", tmpfile.Name(), dst)
|
||||
return fmt.Errorf("error copying tempfile %s to dst %s: %w", tmpfile.Name(), dst, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -191,7 +190,7 @@ func (e *execRunner) CopyFrom(f assets.CopyableFile) error {
|
|||
|
||||
perms, err := strconv.ParseInt(f.GetPermissions(), 8, 0)
|
||||
if err != nil || perms > 07777 {
|
||||
return errors.Wrapf(err, "error converting permissions %s to integer", f.GetPermissions())
|
||||
return fmt.Errorf("error converting permissions %s to integer: %w", f.GetPermissions(), err)
|
||||
}
|
||||
|
||||
return writeFile(dst, f, os.FileMode(perms))
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ import (
|
|||
|
||||
"golang.org/x/sync/syncmap"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
)
|
||||
|
|
@ -76,7 +74,7 @@ func (f *FakeCommandRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
|||
}
|
||||
_, err := buf.WriteString(outStr)
|
||||
if err != nil {
|
||||
return rr, errors.Wrap(err, "Writing outStr to FakeCommandRunner's buffer")
|
||||
return rr, fmt.Errorf("Writing outStr to FakeCommandRunner's buffer: %w", err)
|
||||
}
|
||||
rr.Stdout = buf
|
||||
rr.Stderr = buf
|
||||
|
|
@ -118,7 +116,7 @@ func (f *FakeCommandRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error) {
|
|||
}
|
||||
_, err := buf.WriteString(outStr)
|
||||
if err != nil {
|
||||
return sc, errors.Wrap(err, "Writing outStr to FakeCommandRunner's buffer")
|
||||
return sc, fmt.Errorf("Writing outStr to FakeCommandRunner's buffer: %w", err)
|
||||
}
|
||||
rr.Stdout = buf
|
||||
rr.Stderr = buf
|
||||
|
|
@ -136,7 +134,7 @@ func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error {
|
|||
var b bytes.Buffer
|
||||
_, err := io.Copy(&b, file)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading file: %+v", file)
|
||||
return fmt.Errorf("error reading file: %+v: %w", file, err)
|
||||
}
|
||||
f.fileMap.Store(file.GetSourcePath(), b.String())
|
||||
return nil
|
||||
|
|
@ -151,7 +149,7 @@ func (f *FakeCommandRunner) CopyFrom(file assets.CopyableFile) error {
|
|||
b := v.(bytes.Buffer)
|
||||
_, err := io.Copy(file, &b)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error writing file: %+v", file)
|
||||
return fmt.Errorf("error writing file: %+v: %w", file, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/term"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
|
|
@ -166,7 +165,7 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
perms, err := strconv.ParseInt(f.GetPermissions(), 8, 0)
|
||||
if err != nil || perms > 07777 {
|
||||
return errors.Wrapf(err, "error converting permissions %s to integer", f.GetPermissions())
|
||||
return fmt.Errorf("error converting permissions %s to integer: %w", f.GetPermissions(), err)
|
||||
}
|
||||
|
||||
if src != assets.MemorySource {
|
||||
|
|
@ -192,18 +191,18 @@ func (k *kicRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
tmpFolder, err := tempDirectory(detect.MinikubeInstalledViaSnap(), detect.DockerInstalledViaSnap())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "determining temp directory")
|
||||
return fmt.Errorf("determining temp directory: %w", err)
|
||||
}
|
||||
|
||||
tf, err := os.CreateTemp(tmpFolder, "tmpf-memory-asset")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating temporary file")
|
||||
return fmt.Errorf("creating temporary file: %w", err)
|
||||
}
|
||||
defer tf.Close()
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
if err := writeFile(tf.Name(), f, os.FileMode(perms)); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
return fmt.Errorf("write: %w", err)
|
||||
}
|
||||
return k.copy(tf.Name(), dst)
|
||||
}
|
||||
|
|
@ -229,7 +228,7 @@ func tempDirectory(isMinikubeSnap bool, isDockerSnap bool) (string, error) {
|
|||
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "detecting home dir")
|
||||
return "", fmt.Errorf("detecting home dir: %w", err)
|
||||
}
|
||||
return home, nil
|
||||
}
|
||||
|
|
@ -261,7 +260,7 @@ func copyToPodman(src string, dest string) error {
|
|||
cmd := oci.PrefixCmd(exec.Command(oci.Podman, "cp", src, dest))
|
||||
klog.Infof("Run: %v", cmd)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "podman copy %s into %s, output: %s", src, dest, string(out))
|
||||
return fmt.Errorf("podman copy %s into %s, output: %s: %w", src, dest, string(out), err)
|
||||
}
|
||||
} else {
|
||||
file, err := os.Open(src)
|
||||
|
|
@ -276,7 +275,7 @@ func copyToPodman(src string, dest string) error {
|
|||
cmd.Stdin = file
|
||||
klog.Infof("Run: %v", cmd)
|
||||
if err := cmd.Run(); err != nil {
|
||||
return errors.Wrapf(err, "podman copy %s into %s", src, dest)
|
||||
return fmt.Errorf("podman copy %s into %s: %w", src, dest, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -284,7 +283,7 @@ func copyToPodman(src string, dest string) error {
|
|||
|
||||
func copyToDocker(src string, dest string) error {
|
||||
if out, err := oci.PrefixCmd(exec.Command(oci.Docker, "cp", "-a", src, dest)).CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "docker copy %s into %s, output: %s", src, dest, string(out))
|
||||
return fmt.Errorf("docker copy %s into %s, output: %s: %w", src, dest, string(out), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/kballard/go-shellquote"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"k8s.io/klog/v2"
|
||||
|
|
@ -109,7 +108,7 @@ func (s *SSHRunner) client() (*ssh.Client, error) {
|
|||
|
||||
c, err := sshutil.NewSSHClient(s.d)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "new client")
|
||||
return nil, fmt.Errorf("new client: %w", err)
|
||||
}
|
||||
s.c = c
|
||||
return s.c, nil
|
||||
|
|
@ -121,7 +120,7 @@ func (s *SSHRunner) session() (*ssh.Session, error) {
|
|||
getSession := func() (err error) {
|
||||
client, err := s.client()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "new client")
|
||||
return fmt.Errorf("new client: %w", err)
|
||||
}
|
||||
|
||||
sess, err = client.NewSession()
|
||||
|
|
@ -147,7 +146,7 @@ func (s *SSHRunner) Remove(f assets.CopyableFile) error {
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting ssh session")
|
||||
return fmt.Errorf("getting ssh session: %w", err)
|
||||
}
|
||||
|
||||
defer sess.Close()
|
||||
|
|
@ -158,12 +157,12 @@ func (s *SSHRunner) Remove(f assets.CopyableFile) error {
|
|||
func teeSSH(s *ssh.Session, cmd string, outB io.Writer, errB io.Writer) error {
|
||||
outPipe, err := s.StdoutPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "stdout")
|
||||
return fmt.Errorf("stdout: %w", err)
|
||||
}
|
||||
|
||||
errPipe, err := s.StderrPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "stderr")
|
||||
return fmt.Errorf("stderr: %w", err)
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
|
|
@ -213,7 +212,7 @@ func (s *SSHRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return rr, errors.Wrap(err, "NewSession")
|
||||
return rr, fmt.Errorf("NewSession: %w", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
|
@ -245,12 +244,12 @@ func (s *SSHRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
|||
func teeSSHStart(s *ssh.Session, cmd string, outB io.Writer, errB io.Writer, wg *sync.WaitGroup) error {
|
||||
outPipe, err := s.StdoutPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "stdout")
|
||||
return fmt.Errorf("stdout: %w", err)
|
||||
}
|
||||
|
||||
errPipe, err := s.StderrPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "stderr")
|
||||
return fmt.Errorf("stderr: %w", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
|
@ -303,7 +302,7 @@ func (s *SSHRunner) StartCmd(cmd *exec.Cmd) (*StartedCmd, error) {
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return sc, errors.Wrap(err, "NewSession")
|
||||
return sc, fmt.Errorf("NewSession: %w", err)
|
||||
}
|
||||
|
||||
s.s = sess
|
||||
|
|
@ -366,7 +365,7 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "NewSession")
|
||||
return fmt.Errorf("NewSession: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sess.Close(); err != nil {
|
||||
|
|
@ -378,7 +377,7 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
w, err := sess.StdinPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "StdinPipe")
|
||||
return fmt.Errorf("StdinPipe: %w", err)
|
||||
}
|
||||
// The scpcmd below *should not* return until all data is copied and the
|
||||
// StdinPipe is closed. But let's use errgroup to make it explicit.
|
||||
|
|
@ -395,7 +394,7 @@ func (s *SSHRunner) Copy(f assets.CopyableFile) error {
|
|||
|
||||
copied, err := io.Copy(w, f)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "io.Copy")
|
||||
return fmt.Errorf("io.Copy: %w", err)
|
||||
}
|
||||
if copied != int64(f.GetLength()) {
|
||||
return fmt.Errorf("%s: expected to copy %d bytes, but copied %d instead", f.GetTargetName(), f.GetLength(), copied)
|
||||
|
|
@ -425,7 +424,7 @@ func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error {
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "NewSession")
|
||||
return fmt.Errorf("NewSession: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sess.Close(); err != nil {
|
||||
|
|
@ -450,11 +449,11 @@ func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error {
|
|||
|
||||
r, err := sess.StdoutPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "StdoutPipe")
|
||||
return fmt.Errorf("StdoutPipe: %w", err)
|
||||
}
|
||||
w, err := sess.StdinPipe()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "StdinPipe")
|
||||
return fmt.Errorf("StdinPipe: %w", err)
|
||||
}
|
||||
// The scpcmd below *should not* return until all data is copied and the
|
||||
// StdinPipe is closed. But let's use errgroup to make it explicit.
|
||||
|
|
@ -467,7 +466,7 @@ func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error {
|
|||
fmt.Fprint(w, "\x00")
|
||||
b, err := br.ReadBytes('\n')
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "ReadBytes")
|
||||
return fmt.Errorf("ReadBytes: %w", err)
|
||||
}
|
||||
if b[0] != 'C' {
|
||||
return fmt.Errorf("unexpected: %v", b)
|
||||
|
|
@ -478,7 +477,7 @@ func (s *SSHRunner) CopyFrom(f assets.CopyableFile) error {
|
|||
for copied < int64(length) {
|
||||
n, err := io.CopyN(f, br, int64(length))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "io.CopyN")
|
||||
return fmt.Errorf("io.CopyN: %w", err)
|
||||
}
|
||||
copied += n
|
||||
}
|
||||
|
|
@ -528,12 +527,12 @@ func (s *SSHRunner) ReadableFile(sourcePath string) (assets.ReadableFile, error)
|
|||
|
||||
sess, err := s.session()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewSession")
|
||||
return nil, fmt.Errorf("NewSession: %w", err)
|
||||
}
|
||||
|
||||
r, err := sess.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "StdOutPipe")
|
||||
return nil, fmt.Errorf("StdOutPipe: %w", err)
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf("cat %s", sourcePath)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
|
@ -213,7 +214,7 @@ func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...
|
|||
if os.IsNotExist(err) {
|
||||
return nil, &ErrNotExist{fmt.Sprintf("cluster %q does not exist", profileName)}
|
||||
}
|
||||
return nil, errors.Wrap(err, "stat")
|
||||
return nil, fmt.Errorf("stat: %w", err)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
|
|
@ -221,11 +222,11 @@ func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...
|
|||
if os.IsPermission(err) {
|
||||
return nil, &ErrPermissionDenied{err.Error()}
|
||||
}
|
||||
return nil, errors.Wrap(err, "read")
|
||||
return nil, fmt.Errorf("read: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &cc); err != nil {
|
||||
return nil, errors.Wrap(err, "unmarshal")
|
||||
return nil, fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
return &cc, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import (
|
|||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/cenkalti/backoff/v5"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
|
|
@ -98,7 +97,7 @@ func (r *Containerd) Version() (string, error) {
|
|||
c := exec.Command("containerd", "--version")
|
||||
rr, err := r.Runner.RunCmd(c)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "containerd check version")
|
||||
return "", fmt.Errorf("containerd check version: %w", err)
|
||||
}
|
||||
version, err := parseContainerdVersion(rr.Stdout.String())
|
||||
if err != nil {
|
||||
|
|
@ -124,7 +123,7 @@ func (r *Containerd) Active() bool {
|
|||
func (r *Containerd) Available() error {
|
||||
c := exec.Command("which", "containerd")
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "check containerd availability")
|
||||
return fmt.Errorf("check containerd availability: %w", err)
|
||||
}
|
||||
return checkCNIPlugins(r.KubernetesVersion)
|
||||
}
|
||||
|
|
@ -133,10 +132,10 @@ func (r *Containerd) Available() error {
|
|||
func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semver.Version, cgroupDriver string, insecureRegistry []string, inUserNamespace bool) error {
|
||||
pauseImage := images.Pause(kv, imageRepository)
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^( *)sandbox_image = .*$|\1sandbox_image = %q|' %s`, pauseImage, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "update sandbox_image")
|
||||
return fmt.Errorf("update sandbox_image: %w", err)
|
||||
}
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^( *)restrict_oom_score_adj = .*$|\1restrict_oom_score_adj = %t|' %s`, inUserNamespace, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "update restrict_oom_score_adj")
|
||||
return fmt.Errorf("update restrict_oom_score_adj: %w", err)
|
||||
}
|
||||
|
||||
// configure cgroup driver
|
||||
|
|
@ -147,26 +146,26 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
klog.Infof("configuring containerd to use %q as cgroup driver...", cgroupDriver)
|
||||
useSystemd := cgroupDriver == constants.SystemdCgroupDriver
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^( *)SystemdCgroup = .*$|\1SystemdCgroup = %t|g' %s`, useSystemd, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring SystemdCgroup")
|
||||
return fmt.Errorf("configuring SystemdCgroup: %w", err)
|
||||
}
|
||||
|
||||
// handle deprecated/removed features
|
||||
// ref: https://github.com/containerd/containerd/blob/main/RELEASES.md#deprecated-features
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i 's|"io.containerd.runtime.v1.linux"|"io.containerd.runc.v2"|g' %s`, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring io.containerd.runtime version")
|
||||
return fmt.Errorf("configuring io.containerd.runtime version: %w", err)
|
||||
}
|
||||
|
||||
// avoid containerd v1.6.14+ "failed to load plugin io.containerd.grpc.v1.cri" error="invalid plugin config: `systemd_cgroup` only works for runtime io.containerd.runtime.v1.linux" error
|
||||
// that then leads to crictl "getting the runtime version: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService" error
|
||||
// ref: https://github.com/containerd/containerd/issues/4203
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i '/systemd_cgroup/d' %s`, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "removing deprecated systemd_cgroup param")
|
||||
return fmt.Errorf("removing deprecated systemd_cgroup param: %w", err)
|
||||
}
|
||||
|
||||
// "runtime_type" has to be specified and it should be "io.containerd.runc.v2"
|
||||
// ref: https://github.com/containerd/containerd/issues/6964#issuecomment-1132378279
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i 's|"io.containerd.runc.v1"|"io.containerd.runc.v2"|g' %s`, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring io.containerd.runc version")
|
||||
return fmt.Errorf("configuring io.containerd.runc version: %w", err)
|
||||
}
|
||||
|
||||
// ensure conf_dir is using '/etc/cni/net.d'
|
||||
|
|
@ -175,7 +174,7 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
klog.Warningf("unable to remove /etc/cni/net.mk directory: %v", err)
|
||||
}
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^( *)conf_dir = .*$|\1conf_dir = %q|g' %s`, cni.DefaultConfDir, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "update conf_dir")
|
||||
return fmt.Errorf("update conf_dir: %w", err)
|
||||
}
|
||||
|
||||
// enable 'enable_unprivileged_ports' so that containers that run with non-root user can bind to otherwise privilege ports (like coredns v1.11.0+)
|
||||
|
|
@ -185,11 +184,11 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
if kv.GTE(semver.Version{Major: 1, Minor: 22}) {
|
||||
// remove any existing 'enable_unprivileged_ports' settings
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i '/^ *enable_unprivileged_ports = .*/d' %s`, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "removing enable_unprivileged_ports")
|
||||
return fmt.Errorf("removing enable_unprivileged_ports: %w", err)
|
||||
}
|
||||
// add 'enable_unprivileged_ports' with value 'true'
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^( *)\[plugins."io.containerd.grpc.v1.cri"\]|&\n\1 enable_unprivileged_ports = true|' %s`, containerdConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring enable_unprivileged_ports")
|
||||
return fmt.Errorf("configuring enable_unprivileged_ports: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +203,7 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
|
||||
t, err := template.New("hosts.toml").Parse(containerdInsecureRegistryTemplate)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to parse insecure registry template")
|
||||
return fmt.Errorf("unable to parse insecure registry template: %w", err)
|
||||
}
|
||||
opts := struct {
|
||||
InsecureRegistry string
|
||||
|
|
@ -213,13 +212,13 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
}
|
||||
var b bytes.Buffer
|
||||
if err := t.Execute(&b, opts); err != nil {
|
||||
return errors.Wrap(err, "unable to create insecure registry template")
|
||||
return fmt.Errorf("unable to create insecure registry template: %w", err)
|
||||
}
|
||||
regRootPath := path.Join(containerdMirrorsRoot, addr)
|
||||
|
||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -p %s && printf %%s \"%s\" | base64 -d | sudo tee %s", regRootPath, base64.StdEncoding.EncodeToString(b.Bytes()), path.Join(regRootPath, "hosts.toml")))
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "unable to generate insecure registry cfg")
|
||||
return fmt.Errorf("unable to generate insecure registry cfg: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -290,9 +289,9 @@ func (r *Containerd) LoadImage(imagePath string) error {
|
|||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
// Only retry on transient "short read" or "unexpected EOF" errors
|
||||
if strings.Contains(err.Error(), "short read") || strings.Contains(err.Error(), "unexpected EOF") {
|
||||
return errors.Wrapf(err, "ctr images import")
|
||||
return fmt.Errorf("ctr images import: %w", err)
|
||||
}
|
||||
return backoff.Permanent(errors.Wrapf(err, "ctr images import"))
|
||||
return backoff.Permanent(fmt.Errorf("ctr images import: %w", err))
|
||||
}
|
||||
return nil
|
||||
}, 250*time.Millisecond, 2*time.Minute, 3)
|
||||
|
|
@ -308,7 +307,7 @@ func (r *Containerd) SaveImage(name string, destPath string) error {
|
|||
klog.Infof("Saving image %s: %s", name, destPath)
|
||||
c := exec.Command("sudo", "ctr", "-n=k8s.io", "images", "export", destPath, name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "ctr images export")
|
||||
return fmt.Errorf("ctr images export: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -323,7 +322,7 @@ func (r *Containerd) TagImage(source string, target string) error {
|
|||
klog.Infof("Tagging image %s: %s", source, target)
|
||||
c := exec.Command("sudo", "ctr", "-n=k8s.io", "images", "tag", source, target)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "ctr images tag")
|
||||
return fmt.Errorf("ctr images tag: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -426,7 +425,7 @@ func (r *Containerd) BuildImage(src string, file string, tag string, push bool,
|
|||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "buildctl build")
|
||||
return fmt.Errorf("buildctl build: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -436,7 +435,7 @@ func (r *Containerd) PushImage(name string) error {
|
|||
klog.Infof("Pushing image %s", name)
|
||||
c := exec.Command("sudo", "ctr", "-n=k8s.io", "images", "push", name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "ctr images push")
|
||||
return fmt.Errorf("ctr images push: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -536,7 +535,7 @@ func (r *Containerd) Preload(cc config.ClusterConfig) error {
|
|||
// If images already exist, return
|
||||
imgs, err := images.Kubeadm(cc.KubernetesConfig.ImageRepository, k8sVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting images")
|
||||
return fmt.Errorf("getting images: %w", err)
|
||||
}
|
||||
if containerdImagesPreloaded(r.Runner, imgs) {
|
||||
klog.Info("Images already preloaded, skipping extraction")
|
||||
|
|
@ -556,7 +555,7 @@ func (r *Containerd) Preload(cc config.ClusterConfig) error {
|
|||
// Copy over tarball into host
|
||||
fa, err := assets.NewFileAsset(tarballPath, targetDir, targetName, "0644")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting file asset")
|
||||
return fmt.Errorf("getting file asset: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := fa.Close(); err != nil {
|
||||
|
|
@ -566,14 +565,14 @@ func (r *Containerd) Preload(cc config.ClusterConfig) error {
|
|||
|
||||
t := time.Now()
|
||||
if err := r.Runner.Copy(fa); err != nil {
|
||||
return errors.Wrap(err, "copying file")
|
||||
return fmt.Errorf("copying file: %w", err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to copy over tarball", time.Since(t))
|
||||
|
||||
t = time.Now()
|
||||
// extract the tarball to /var in the VM
|
||||
if rr, err := r.Runner.RunCmd(exec.Command("sudo", "tar", "--xattrs", "--xattrs-include", "security.capability", "-I", "lz4", "-C", "/var", "-xf", dest)); err != nil {
|
||||
return errors.Wrapf(err, "extracting tarball: %s", rr.Output())
|
||||
return fmt.Errorf("extracting tarball: %s: %w", rr.Output(), err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to extract the tarball", time.Since(t))
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import (
|
|||
|
||||
"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"
|
||||
|
|
@ -86,7 +84,7 @@ func crictlList(cr CommandRunner, root string, o ListContainersOptions) (*comman
|
|||
func listCRIContainers(cr CommandRunner, root string, o ListContainersOptions) ([]string, error) {
|
||||
rr, err := crictlList(cr, root, o)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "crictl list")
|
||||
return nil, fmt.Errorf("crictl list: %w", err)
|
||||
}
|
||||
|
||||
// Avoid an id named ""
|
||||
|
|
@ -117,7 +115,7 @@ 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 {
|
||||
return nil, errors.Wrap(err, "runc")
|
||||
return nil, fmt.Errorf("runc: %w", err)
|
||||
}
|
||||
content := rr.Stdout.Bytes()
|
||||
klog.Infof("JSON = %s", content)
|
||||
|
|
@ -158,7 +156,7 @@ func pauseCRIContainers(cr CommandRunner, root string, ids []string) error {
|
|||
args := baseArgs
|
||||
args = append(args, id)
|
||||
if _, err := cr.RunCmd(exec.Command("sudo", args...)); err != nil {
|
||||
return errors.Wrap(err, "runc")
|
||||
return fmt.Errorf("runc: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -185,7 +183,7 @@ func unpauseCRIContainers(cr CommandRunner, root string, ids []string) error {
|
|||
for _, id := range ids {
|
||||
cargs := append(cargs, id)
|
||||
if _, err := cr.RunCmd(exec.Command("sudo", cargs...)); err != nil {
|
||||
return errors.Wrap(err, "runc")
|
||||
return fmt.Errorf("runc: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -202,7 +200,7 @@ func killCRIContainers(cr CommandRunner, ids []string) error {
|
|||
args := append([]string{crictl, "rm", "--force"}, ids...)
|
||||
c := exec.Command("sudo", args...)
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crictl")
|
||||
return fmt.Errorf("crictl: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -215,7 +213,7 @@ func pullCRIImage(cr CommandRunner, name string) error {
|
|||
args := append([]string{crictl, "pull"}, name)
|
||||
c := exec.Command("sudo", args...)
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crictl")
|
||||
return fmt.Errorf("crictl: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -240,7 +238,7 @@ func removeCRIImage(cr CommandRunner, name string, verifyRemoval bool) error {
|
|||
}
|
||||
|
||||
if !success {
|
||||
return errors.Wrap(err, "crictl")
|
||||
return fmt.Errorf("crictl: %w", err)
|
||||
}
|
||||
|
||||
if !verifyRemoval {
|
||||
|
|
@ -261,7 +259,7 @@ func removeCRIImage(cr CommandRunner, name string, verifyRemoval bool) error {
|
|||
}
|
||||
|
||||
if err := retry.Expo(checkFunc, 250*time.Millisecond, 10*time.Second); err != nil {
|
||||
return errors.Wrapf(err, "image %s still exists after removal", name)
|
||||
return fmt.Errorf("image %s still exists after removal: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -281,7 +279,7 @@ func stopCRIContainers(cr CommandRunner, ids []string) error {
|
|||
args := append([]string{crictl, "stop", "--timeout=10"}, ids...)
|
||||
c := exec.Command("sudo", args...)
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crictl")
|
||||
return fmt.Errorf("crictl: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -301,7 +299,7 @@ func populateCRIConfig(cr CommandRunner, socket string) error {
|
|||
}
|
||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -p %s && printf %%s \"%s\" | sudo tee %s", path.Dir(cPath), b.String(), cPath))
|
||||
if rr, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "Run: %q", rr.Command())
|
||||
return fmt.Errorf("Run: %q: %w", rr.Command(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -312,7 +310,7 @@ func getCRIInfo(cr CommandRunner) (map[string]interface{}, error) {
|
|||
c := exec.Command("sudo", args...)
|
||||
rr, err := cr.RunCmd(c)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get cri info")
|
||||
return nil, fmt.Errorf("get cri info: %w", err)
|
||||
}
|
||||
info := rr.Stdout.String()
|
||||
jsonMap := make(map[string]interface{})
|
||||
|
|
@ -328,7 +326,7 @@ func listCRIImages(cr CommandRunner) ([]ListImage, error) {
|
|||
c := exec.Command("sudo", "crictl", timeoutOverrideFlag, "images", "--output", "json")
|
||||
rr, err := cr.RunCmd(c)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "crictl images")
|
||||
return nil, fmt.Errorf("crictl images: %w", err)
|
||||
}
|
||||
|
||||
var jsonImages crictlImages
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
|
|
@ -59,7 +58,7 @@ func generateCRIOConfig(cr CommandRunner, imageRepository string, kv semver.Vers
|
|||
klog.Infof("configure cri-o to use %q pause image...", pauseImage)
|
||||
c := exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i 's|^.*pause_image = .*$|pause_image = %q|' %s`, pauseImage, crioConfigFile))
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "update pause_image")
|
||||
return fmt.Errorf("update pause_image: %w", err)
|
||||
}
|
||||
|
||||
// configure cgroup driver
|
||||
|
|
@ -69,7 +68,7 @@ func generateCRIOConfig(cr CommandRunner, imageRepository string, kv semver.Vers
|
|||
}
|
||||
klog.Infof("configuring cri-o to use %q as cgroup driver...", cgroupDriver)
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i 's|^.*cgroup_manager = .*$|cgroup_manager = %q|' %s`, cgroupDriver, crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring cgroup_manager")
|
||||
return fmt.Errorf("configuring cgroup_manager: %w", err)
|
||||
}
|
||||
// explicitly set conmon_cgroup to avoid errors like:
|
||||
// - level=fatal msg="Validating runtime config: conmon cgroup should be 'pod' or a systemd slice"
|
||||
|
|
@ -78,10 +77,10 @@ func generateCRIOConfig(cr CommandRunner, imageRepository string, kv semver.Vers
|
|||
// ref: https://github.com/cri-o/cri-o/issues/6047
|
||||
// ref: https://kubernetes.io/docs/setup/production-environment/container-runtimes/#cgroup-driver
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i '/conmon_cgroup = .*/d' %s`, crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "removing conmon_cgroup")
|
||||
return fmt.Errorf("removing conmon_cgroup: %w", err)
|
||||
}
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i '/cgroup_manager = .*/a conmon_cgroup = %q' %s`, "pod", crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring conmon_cgroup")
|
||||
return fmt.Errorf("configuring conmon_cgroup: %w", err)
|
||||
}
|
||||
|
||||
// we might still want to try removing '/etc/cni/net.mk' in case of upgrade from previous minikube version that had/used it
|
||||
|
|
@ -95,15 +94,15 @@ func generateCRIOConfig(cr CommandRunner, imageRepository string, kv semver.Vers
|
|||
if kv.GTE(semver.Version{Major: 1, Minor: 22}) {
|
||||
// remove any existing 'net.ipv4.ip_unprivileged_port_start' settings
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i '/^ *"net.ipv4.ip_unprivileged_port_start=.*"/d' %s`, crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "removing net.ipv4.ip_unprivileged_port_start")
|
||||
return fmt.Errorf("removing net.ipv4.ip_unprivileged_port_start: %w", err)
|
||||
}
|
||||
// insert 'default_sysctls' list, if not already present
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo grep -q "^ *default_sysctls" %s || sudo sed -i '/conmon_cgroup = .*/a default_sysctls = \[\n\]' %s`, crioConfigFile, crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "inserting default_sysctls")
|
||||
return fmt.Errorf("inserting default_sysctls: %w", err)
|
||||
}
|
||||
// add 'net.ipv4.ip_unprivileged_port_start' to 'default_sysctls' list
|
||||
if _, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf(`sudo sed -i -r 's|^default_sysctls *= *\[|&\n "net.ipv4.ip_unprivileged_port_start=0",|' %s`, crioConfigFile))); err != nil {
|
||||
return errors.Wrap(err, "configuring net.ipv4.ip_unprivileged_port_start")
|
||||
return fmt.Errorf("configuring net.ipv4.ip_unprivileged_port_start: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +124,7 @@ func (r *CRIO) Version() (string, error) {
|
|||
c := exec.Command("crio", "--version")
|
||||
rr, err := r.Runner.RunCmd(c)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "crio version")
|
||||
return "", fmt.Errorf("crio version: %w", err)
|
||||
}
|
||||
|
||||
// crio version 1.13.0
|
||||
|
|
@ -146,7 +145,7 @@ func (r *CRIO) SocketPath() string {
|
|||
func (r *CRIO) Available() error {
|
||||
c := exec.Command("which", "crio")
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "check crio available")
|
||||
return fmt.Errorf("check crio available: %w", err)
|
||||
}
|
||||
return checkCNIPlugins(r.KubernetesVersion)
|
||||
}
|
||||
|
|
@ -171,7 +170,7 @@ func enableIPForwarding(cr CommandRunner) error {
|
|||
}
|
||||
c = exec.Command("sudo", "sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward")
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "ip_forward")
|
||||
return fmt.Errorf("ip_forward: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -192,13 +191,13 @@ Environment="_CRIO_ROOTLESS=1"
|
|||
targetDir := filepath.Dir(target)
|
||||
c := exec.Command("sudo", "mkdir", "-p", targetDir)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "failed to create directory %q", targetDir)
|
||||
return fmt.Errorf("failed to create directory %q: %w", targetDir, err)
|
||||
}
|
||||
asset := assets.NewMemoryAssetTarget([]byte(content), target, "0644")
|
||||
err := r.Runner.Copy(asset)
|
||||
asset.Close()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create %q", target)
|
||||
return fmt.Errorf("failed to create %q: %w", target, err)
|
||||
}
|
||||
}
|
||||
// reload systemd to apply our changes on /etc/systemd
|
||||
|
|
@ -275,7 +274,7 @@ func (r *CRIO) LoadImage(imgPath string) error {
|
|||
klog.Infof("Loading image: %s", imgPath)
|
||||
c := exec.Command("sudo", "podman", "load", "-i", imgPath)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio load image")
|
||||
return fmt.Errorf("crio load image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -290,7 +289,7 @@ func (r *CRIO) SaveImage(name string, destPath string) error {
|
|||
klog.Infof("Saving image %s: %s", name, destPath)
|
||||
c := exec.Command("sudo", "podman", "save", name, "-o", destPath)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio save image")
|
||||
return fmt.Errorf("crio save image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -305,7 +304,7 @@ func (r *CRIO) TagImage(source string, target string) error {
|
|||
klog.Infof("Tagging image %s: %s", source, target)
|
||||
c := exec.Command("sudo", "podman", "tag", source, target)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio tag image")
|
||||
return fmt.Errorf("crio tag image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -332,14 +331,14 @@ func (r *CRIO) BuildImage(src string, file string, tag string, push bool, env []
|
|||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio build image")
|
||||
return fmt.Errorf("crio build image: %w", err)
|
||||
}
|
||||
if tag != "" && push {
|
||||
c := exec.Command("sudo", "podman", "push", tag)
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio push image")
|
||||
return fmt.Errorf("crio push image: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -350,7 +349,7 @@ func (r *CRIO) PushImage(name string) error {
|
|||
klog.Infof("Pushing image %s", name)
|
||||
c := exec.Command("sudo", "podman", "push", name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "crio push image")
|
||||
return fmt.Errorf("crio push image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -427,7 +426,7 @@ func (r *CRIO) Preload(cc config.ClusterConfig) error {
|
|||
// If images already exist, return
|
||||
imgs, err := images.Kubeadm(cc.KubernetesConfig.ImageRepository, k8sVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting images")
|
||||
return fmt.Errorf("getting images: %w", err)
|
||||
}
|
||||
if crioImagesPreloaded(r.Runner, imgs) {
|
||||
klog.Info("Images already preloaded, skipping extraction")
|
||||
|
|
@ -481,7 +480,7 @@ func (r *CRIO) Preload(cc config.ClusterConfig) error {
|
|||
// Copy over tarball into host
|
||||
fa, err := assets.NewFileAsset(tarballPath, targetDir, targetName, "0644")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting file asset")
|
||||
return fmt.Errorf("getting file asset: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := fa.Close(); err != nil {
|
||||
|
|
@ -491,14 +490,14 @@ func (r *CRIO) Preload(cc config.ClusterConfig) error {
|
|||
|
||||
t := time.Now()
|
||||
if err := r.Runner.Copy(fa); err != nil {
|
||||
return errors.Wrap(err, "copying file")
|
||||
return fmt.Errorf("copying file: %w", err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to copy over tarball", time.Since(t))
|
||||
|
||||
t = time.Now()
|
||||
// extract the tarball to /var in the VM
|
||||
if rr, err := r.Runner.RunCmd(exec.Command("sudo", "tar", "--xattrs", "--xattrs-include", "security.capability", "-I", "lz4", "-C", "/var", "-xf", dest)); err != nil {
|
||||
return errors.Wrapf(err, "extracting tarball: %s", rr.Output())
|
||||
return fmt.Errorf("extracting tarball: %s: %w", rr.Output(), err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to extract the tarball", time.Since(t))
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
|
|
@ -319,7 +320,7 @@ func compatibleWithVersion(runtime, v string) error {
|
|||
func CheckCompatibility(cr Manager) error {
|
||||
v, err := cr.Version()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to check container runtime version")
|
||||
return fmt.Errorf("Failed to check container runtime version: %w", err)
|
||||
}
|
||||
return compatibleWithVersion(cr.Name(), v)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/blang/semver/v4"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
|
|
@ -218,7 +217,7 @@ func buffer(s string, err error) (*command.RunResult, error) {
|
|||
var buf bytes.Buffer
|
||||
_, err = buf.WriteString(s)
|
||||
if err != nil {
|
||||
return rr, errors.Wrap(err, "Writing outStr to FakeRunner's buffer")
|
||||
return rr, fmt.Errorf("Writing outStr to FakeRunner's buffer: %w", err)
|
||||
}
|
||||
rr.Stdout = buf
|
||||
rr.Stderr = buf
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
|
||||
"github.com/blang/semver/v4"
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
|
|
@ -268,7 +267,7 @@ func (r *Docker) ListImages(ListImagesOptions) ([]ListImage, error) {
|
|||
c := exec.Command("docker", "images", "--no-trunc", "--format", "{{json .}}")
|
||||
rr, err := r.Runner.RunCmd(c)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "docker images")
|
||||
return nil, fmt.Errorf("docker images: %w", err)
|
||||
}
|
||||
type dockerImage struct {
|
||||
ID string `json:"ID"`
|
||||
|
|
@ -285,11 +284,11 @@ func (r *Docker) ListImages(ListImagesOptions) ([]ListImage, error) {
|
|||
|
||||
var jsonImage dockerImage
|
||||
if err := json.Unmarshal([]byte(img), &jsonImage); err != nil {
|
||||
return nil, errors.Wrap(err, "Image convert problem")
|
||||
return nil, fmt.Errorf("Image convert problem: %w", err)
|
||||
}
|
||||
size, err := units.FromHumanSize(jsonImage.Size)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Image size convert problem")
|
||||
return nil, fmt.Errorf("Image size convert problem: %w", err)
|
||||
}
|
||||
|
||||
repoTag := fmt.Sprintf("%s:%s", jsonImage.Repository, jsonImage.Tag)
|
||||
|
|
@ -308,7 +307,7 @@ func (r *Docker) LoadImage(imgPath string) error {
|
|||
klog.Infof("Loading image: %s", imgPath)
|
||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo cat %s | docker load", imgPath))
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "loadimage docker")
|
||||
return fmt.Errorf("loadimage docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -321,7 +320,7 @@ func (r *Docker) PullImage(name string) error {
|
|||
}
|
||||
c := exec.Command("docker", "pull", name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "pull image docker")
|
||||
return fmt.Errorf("pull image docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -331,7 +330,7 @@ func (r *Docker) SaveImage(name string, imagePath string) error {
|
|||
klog.Infof("Saving image %s: %s", name, imagePath)
|
||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("docker save '%s' | sudo tee %s >/dev/null", name, imagePath))
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "saveimage docker")
|
||||
return fmt.Errorf("saveimage docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -344,7 +343,7 @@ func (r *Docker) RemoveImage(name string) error {
|
|||
}
|
||||
c := exec.Command("docker", "rmi", name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "remove image docker")
|
||||
return fmt.Errorf("remove image docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -354,7 +353,7 @@ func (r *Docker) TagImage(source string, target string) error {
|
|||
klog.Infof("Tagging image %s: %s", source, target)
|
||||
c := exec.Command("docker", "tag", source, target)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "tag image docker")
|
||||
return fmt.Errorf("tag image docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -380,14 +379,14 @@ func (r *Docker) BuildImage(src string, file string, tag string, push bool, env
|
|||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "buildimage docker")
|
||||
return fmt.Errorf("buildimage docker: %w", err)
|
||||
}
|
||||
if tag != "" && push {
|
||||
c := exec.Command("docker", "push", tag)
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "pushimage docker")
|
||||
return fmt.Errorf("pushimage docker: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -398,7 +397,7 @@ func (r *Docker) PushImage(name string) error {
|
|||
klog.Infof("Pushing image: %s", name)
|
||||
c := exec.Command("docker", "push", name)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "push image docker")
|
||||
return fmt.Errorf("push image docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -448,7 +447,7 @@ func (r *Docker) ListContainers(o ListContainersOptions) ([]string, error) {
|
|||
args = append(args, fmt.Sprintf("--filter=name=%s", nameFilter), "--format={{.ID}}")
|
||||
rr, err := r.Runner.RunCmd(exec.Command("docker", args...))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "docker")
|
||||
return nil, fmt.Errorf("docker: %w", err)
|
||||
}
|
||||
var ids []string
|
||||
for _, line := range strings.Split(rr.Stdout.String(), "\n") {
|
||||
|
|
@ -471,7 +470,7 @@ func (r *Docker) KillContainers(ids []string) error {
|
|||
args := append([]string{"rm", "-f"}, ids...)
|
||||
c := exec.Command("docker", args...)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "killing containers docker")
|
||||
return fmt.Errorf("killing containers docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -488,7 +487,7 @@ func (r *Docker) StopContainers(ids []string) error {
|
|||
args := append([]string{"stop"}, ids...)
|
||||
c := exec.Command("docker", args...)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "docker")
|
||||
return fmt.Errorf("docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -505,7 +504,7 @@ func (r *Docker) PauseContainers(ids []string) error {
|
|||
args := append([]string{"pause"}, ids...)
|
||||
c := exec.Command("docker", args...)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "docker")
|
||||
return fmt.Errorf("docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -522,7 +521,7 @@ func (r *Docker) UnpauseContainers(ids []string) error {
|
|||
args := append([]string{"unpause"}, ids...)
|
||||
c := exec.Command("docker", args...)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
return errors.Wrap(err, "docker")
|
||||
return fmt.Errorf("docker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -618,7 +617,7 @@ func (r *Docker) Preload(cc config.ClusterConfig) error {
|
|||
// If images already exist, return
|
||||
imgs, err := images.Kubeadm(cc.KubernetesConfig.ImageRepository, k8sVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting images")
|
||||
return fmt.Errorf("getting images: %w", err)
|
||||
}
|
||||
if dockerImagesPreloaded(r.Runner, imgs) {
|
||||
klog.Info("Images already preloaded, skipping extraction")
|
||||
|
|
@ -643,7 +642,7 @@ func (r *Docker) Preload(cc config.ClusterConfig) error {
|
|||
// Copy over tarball into host
|
||||
fa, err := assets.NewFileAsset(tarballPath, targetDir, targetName, "0644")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting file asset")
|
||||
return fmt.Errorf("getting file asset: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := fa.Close(); err != nil {
|
||||
|
|
@ -653,13 +652,13 @@ func (r *Docker) Preload(cc config.ClusterConfig) error {
|
|||
|
||||
t := time.Now()
|
||||
if err := r.Runner.Copy(fa); err != nil {
|
||||
return errors.Wrap(err, "copying file")
|
||||
return fmt.Errorf("copying file: %w", err)
|
||||
}
|
||||
klog.Infof("duration metric: took %s to copy over tarball", time.Since(t))
|
||||
|
||||
// extract the tarball to /var in the VM
|
||||
if rr, err := r.Runner.RunCmd(exec.Command("sudo", "tar", "--xattrs", "--xattrs-include", "security.capability", "-I", "lz4", "-C", "/var", "-xf", dest)); err != nil {
|
||||
return errors.Wrapf(err, "extracting tarball: %s", rr.Output())
|
||||
return fmt.Errorf("extracting tarball: %s: %w", rr.Output(), err)
|
||||
}
|
||||
|
||||
// remove the tarball in the VM
|
||||
|
|
@ -802,16 +801,16 @@ ExecStart={{.ExecPath}} --container-runtime-endpoint fd:// --pod-infra-container
|
|||
|
||||
b := bytes.Buffer{}
|
||||
if err := CRIDockerServiceConfTemplate.Execute(&b, opts); err != nil {
|
||||
return errors.Wrap(err, "failed to execute template")
|
||||
return fmt.Errorf("failed to execute template: %w", err)
|
||||
}
|
||||
criDockerService := b.Bytes()
|
||||
c := exec.Command("sudo", "mkdir", "-p", path.Dir(CRIDockerServiceConfFile))
|
||||
if _, err := cr.RunCmd(c); err != nil {
|
||||
return errors.Wrapf(err, "failed to create directory")
|
||||
return fmt.Errorf("failed to create directory: %w", err)
|
||||
}
|
||||
svc := assets.NewMemoryAssetTarget(criDockerService, CRIDockerServiceConfFile, "0644")
|
||||
if err := cr.Copy(svc); err != nil {
|
||||
return errors.Wrap(err, "failed to copy template")
|
||||
return fmt.Errorf("failed to copy template: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"runtime"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
|
|
@ -82,12 +81,12 @@ func Binary(binary, version, osName, archName, binaryURL string) (string, error)
|
|||
}
|
||||
|
||||
if err := download(url, targetFilepath); err != nil {
|
||||
return "", errors.Wrapf(err, "download failed: %s", url)
|
||||
return "", fmt.Errorf("download failed: %s: %w", url, err)
|
||||
}
|
||||
|
||||
if osName == runtime.GOOS && archName == runtime.GOARCH {
|
||||
if err = os.Chmod(targetFilepath, 0755); err != nil {
|
||||
return "", errors.Wrapf(err, "chmod +x %s", targetFilepath)
|
||||
return "", fmt.Errorf("chmod +x %s: %w", targetFilepath, err)
|
||||
}
|
||||
}
|
||||
return targetFilepath, nil
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
|
||||
"github.com/hashicorp/go-getter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
|
@ -57,7 +56,7 @@ func SetAliyunMirror() {
|
|||
// CreateDstDownloadMock is the default mock implementation of download.
|
||||
func CreateDstDownloadMock(_, dst string) error {
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil {
|
||||
return errors.Wrap(err, "mkdir")
|
||||
return fmt.Errorf("mkdir: %w", err)
|
||||
}
|
||||
|
||||
f, err := os.Create(dst)
|
||||
|
|
@ -98,7 +97,7 @@ func download(src, dst string, options ...getter.ClientOption) error {
|
|||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
|
||||
return errors.Wrap(err, "mkdir")
|
||||
return fmt.Errorf("mkdir: %w", err)
|
||||
}
|
||||
|
||||
if DownloadMock != nil {
|
||||
|
|
@ -113,7 +112,7 @@ func download(src, dst string, options ...getter.ClientOption) error {
|
|||
|
||||
klog.Infof("Downloading: %s -> %s", src, dst)
|
||||
if err := client.Get(); err != nil {
|
||||
return errors.Wrapf(err, "getter: %+v", client)
|
||||
return fmt.Errorf("getter: %+v: %w", client, err)
|
||||
}
|
||||
return os.Rename(tmpDst, dst)
|
||||
}
|
||||
|
|
@ -141,7 +140,7 @@ func lockDownload(file string) (lock.Releaser, error) {
|
|||
spec.Timeout = 5 * time.Minute
|
||||
releaser, err := lock.Acquire(spec)
|
||||
if err != nil {
|
||||
lockChannel <- retPair{nil, errors.Wrapf(err, "failed to acquire lock \"%s\": %+v", file, spec)}
|
||||
lockChannel <- retPair{nil, fmt.Errorf("failed to acquire lock \"%s\": %+v: %w", file, spec, err)}
|
||||
return
|
||||
}
|
||||
lockChannel <- retPair{releaser, err}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"runtime"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
"k8s.io/minikube/pkg/minikube/style"
|
||||
|
|
@ -45,7 +44,7 @@ func Driver(name string, destination string, v semver.Version) error {
|
|||
if err := download(archURL, destination); err != nil {
|
||||
klog.Infof("failed to download arch specific driver: %v. trying to get the common version", err)
|
||||
if err := download(driverWithChecksumURL(name, v), destination); err != nil {
|
||||
return errors.Wrap(err, "download")
|
||||
return fmt.Errorf("download: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/cheggaaa/pb/v3"
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
|
|
@ -33,7 +35,6 @@ import (
|
|||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
"github.com/hashicorp/go-getter"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/image"
|
||||
|
|
@ -139,7 +140,7 @@ func ImageToCache(img string) error {
|
|||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(f), 0777); err != nil {
|
||||
return errors.Wrapf(err, "making cache image directory: %s", f)
|
||||
return fmt.Errorf("making cache image directory: %s: %w", f, err)
|
||||
}
|
||||
|
||||
if DownloadMock != nil {
|
||||
|
|
@ -150,11 +151,11 @@ func ImageToCache(img string) error {
|
|||
klog.Infof("Writing %s to local cache", img)
|
||||
ref, err := name.ParseReference(img)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing reference")
|
||||
return fmt.Errorf("parsing reference: %w", err)
|
||||
}
|
||||
tag, err := name.NewTag(image.Tag(img))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing tag")
|
||||
return fmt.Errorf("parsing tag: %w", err)
|
||||
}
|
||||
klog.V(3).Infof("Getting image %v", ref)
|
||||
i, err := remote.Image(ref, remote.WithPlatform(defaultPlatform))
|
||||
|
|
@ -167,7 +168,7 @@ func ImageToCache(img string) error {
|
|||
return ErrNeedsLogin
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "getting remote image")
|
||||
return fmt.Errorf("getting remote image: %w", err)
|
||||
}
|
||||
klog.V(3).Infof("Writing image %v", tag)
|
||||
errchan := make(chan error)
|
||||
|
|
@ -219,7 +220,7 @@ func ImageToCache(img string) error {
|
|||
p.Finish()
|
||||
}
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "writing tarball image")
|
||||
return fmt.Errorf("writing tarball image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -260,13 +261,13 @@ func parseImage(img string) (*name.Tag, name.Reference, error) {
|
|||
var ref name.Reference
|
||||
tag, err := name.NewTag(image.Tag(img))
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "failed to parse image reference")
|
||||
return nil, nil, fmt.Errorf("failed to parse image reference: %w", err)
|
||||
}
|
||||
digest, err := name.NewDigest(img)
|
||||
if err != nil {
|
||||
_, ok := err.(*name.ErrBadName)
|
||||
if !ok {
|
||||
return nil, nil, errors.Wrap(err, "new ref")
|
||||
return nil, nil, fmt.Errorf("new ref: %w", err)
|
||||
}
|
||||
// ErrBadName means img contains no digest
|
||||
// It happens if its value is name:tag for example.
|
||||
|
|
@ -297,7 +298,7 @@ func CacheToDaemon(img string) (string, error) {
|
|||
|
||||
i, err := tarball.ImageFromPath(p, tag)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "tarball")
|
||||
return "", fmt.Errorf("tarball: %w", err)
|
||||
}
|
||||
|
||||
resp, err := daemon.Write(*tag, i)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
|
@ -106,7 +107,7 @@ func ISO(urls []string, skipChecksum bool) (string, error) {
|
|||
func downloadISO(isoURL string, skipChecksum bool) error {
|
||||
u, err := url.Parse(isoURL)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "url.parse %q", isoURL)
|
||||
return fmt.Errorf("url.parse %q: %w", isoURL, err)
|
||||
}
|
||||
|
||||
// It's already downloaded
|
||||
|
|
@ -117,14 +118,14 @@ func downloadISO(isoURL string, skipChecksum bool) error {
|
|||
// Lock before we check for existence to avoid thundering herd issues
|
||||
dst := localISOPath(u)
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil {
|
||||
return errors.Wrapf(err, "making cache image directory: %s", dst)
|
||||
return fmt.Errorf("making cache image directory: %s: %w", dst, err)
|
||||
}
|
||||
spec := lock.PathMutexSpec(dst)
|
||||
spec.Timeout = 10 * time.Minute
|
||||
klog.Infof("acquiring lock: %+v", spec)
|
||||
releaser, err := lock.Acquire(spec)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to acquire lock for %+v", spec)
|
||||
return fmt.Errorf("unable to acquire lock for %+v: %w", spec, err)
|
||||
}
|
||||
defer releaser.Release()
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import (
|
|||
"cloud.google.com/go/storage"
|
||||
"google.golang.org/api/option"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/download/gh"
|
||||
|
|
@ -277,18 +276,18 @@ func Preload(k8sVersion, containerRuntime, driverName string) error {
|
|||
realPath = targetPath
|
||||
tmp, err := os.CreateTemp(targetDir(), TarballName(k8sVersion, containerRuntime)+".*")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "tempfile")
|
||||
return fmt.Errorf("tempfile: %w", err)
|
||||
}
|
||||
targetPath = tmp.Name()
|
||||
if err := tmp.Close(); err != nil {
|
||||
return errors.Wrap(err, "tempfile close")
|
||||
return fmt.Errorf("tempfile close: %w", err)
|
||||
}
|
||||
} else if checksum != nil { // add URL parameter for go-getter to automatically verify the checksum
|
||||
url = addChecksumToURL(url, source, checksum)
|
||||
}
|
||||
|
||||
if err := download(url, targetPath); err != nil {
|
||||
return errors.Wrapf(err, "download failed: %s", url)
|
||||
return fmt.Errorf("download failed: %s: %w", url, err)
|
||||
}
|
||||
|
||||
// to avoid partial/corrupt files in final dest. only rename tmp if download didn't error out.
|
||||
|
|
@ -296,7 +295,7 @@ func Preload(k8sVersion, containerRuntime, driverName string) error {
|
|||
klog.Infof("renaming tempfile to %s ...", TarballName(k8sVersion, containerRuntime))
|
||||
err := os.Rename(targetPath, realPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "rename")
|
||||
return fmt.Errorf("rename: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -322,11 +321,11 @@ func getStorageAttrs(name string) (*storage.ObjectAttrs, error) {
|
|||
ctx := context.Background()
|
||||
client, err := storage.NewClient(ctx, option.WithoutAuthentication())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting storage client")
|
||||
return nil, fmt.Errorf("getting storage client: %w", err)
|
||||
}
|
||||
attrs, err := client.Bucket(PreloadBucket).Object(name).Attrs(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting storage object")
|
||||
return nil, fmt.Errorf("getting storage object: %w", err)
|
||||
}
|
||||
return attrs, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ func InstallOrUpdate(name string, directory string, interactive bool, autoUpdate
|
|||
v, err := semver.Make("1.37.0")
|
||||
out.WarningT("Hyperkit driver will be removed in the next minikube release, we have other drivers that work on macOS such as docker or qemu, vfkit. Please consider switching to one of them. For more information, please visit: https://minikube.sigs.k8s.io/docs/drivers/hyperkit/")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't parse version")
|
||||
return fmt.Errorf("can't parse version: %w", err)
|
||||
}
|
||||
|
||||
executable := fmt.Sprintf("docker-machine-driver-%s", name)
|
||||
|
|
@ -73,7 +72,7 @@ func InstallOrUpdate(name string, directory string, interactive bool, autoUpdate
|
|||
klog.Infof("acquiring lock: %+v", spec)
|
||||
releaser, err := lock.Acquire(spec)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to acquire lock for %+v", spec)
|
||||
return fmt.Errorf("unable to acquire lock for %+v: %w", spec, err)
|
||||
}
|
||||
defer releaser.Release()
|
||||
|
||||
|
|
@ -134,7 +133,7 @@ func fixDriverPermissions(name string, path string, interactive bool) error {
|
|||
klog.Infof("running: %v", c.Args)
|
||||
err := c.Run()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "%v", c.Args)
|
||||
return fmt.Errorf("%v: %w", c.Args, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -165,7 +164,7 @@ func validateDriver(executable string, v semver.Version) (string, error) {
|
|||
|
||||
driverVersion, err := semver.Make(ev)
|
||||
if err != nil {
|
||||
return path, errors.Wrap(err, "can't parse driver version")
|
||||
return path, fmt.Errorf("can't parse driver version: %w", err)
|
||||
}
|
||||
klog.Infof("%s version is %s", path, driverVersion)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ import (
|
|||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import (
|
|||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// exclude is a list of strings to explicitly omit from translation files.
|
||||
|
|
@ -98,7 +96,7 @@ func newExtractor(functionsToCheck []string) (*state, error) {
|
|||
// Functions must be of the form "package.function"
|
||||
t2 := strings.Split(t, ".")
|
||||
if len(t2) < 2 {
|
||||
return nil, errors.Errorf("invalid function string %s. Needs package name as well", t)
|
||||
return nil, fmt.Errorf("invalid function string %s. Needs package name as well", t)
|
||||
}
|
||||
f := funcType{
|
||||
pack: t2[0],
|
||||
|
|
@ -128,7 +126,7 @@ func TranslatableStrings(paths []string, functions []string, output string) erro
|
|||
e, err := newExtractor(functions)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Initializing")
|
||||
return fmt.Errorf("Initializing: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println("Compiling translation strings...")
|
||||
|
|
@ -148,7 +146,7 @@ func TranslatableStrings(paths []string, functions []string, output string) erro
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Extracting strings")
|
||||
return fmt.Errorf("Extracting strings: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -156,7 +154,7 @@ func TranslatableStrings(paths []string, functions []string, output string) erro
|
|||
err = writeStringsToFiles(e, output)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Writing translation files")
|
||||
return fmt.Errorf("Writing translation files: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println("Done!")
|
||||
|
|
@ -453,7 +451,7 @@ func checkBinaryExpression(b *ast.BinaryExpr) string {
|
|||
func writeStringsToFiles(e *state, output string) error {
|
||||
err := filepath.Walk(output, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "accessing path")
|
||||
return fmt.Errorf("accessing path: %w", err)
|
||||
}
|
||||
if info.Mode().IsDir() {
|
||||
return nil
|
||||
|
|
@ -465,13 +463,13 @@ func writeStringsToFiles(e *state, output string) error {
|
|||
currentTranslations := make(map[string]interface{})
|
||||
f, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading translation file")
|
||||
return fmt.Errorf("reading translation file: %w", err)
|
||||
}
|
||||
// Unmarshal nonempty files
|
||||
if len(f) > 0 {
|
||||
err = json.Unmarshal(f, ¤tTranslations)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unmarshalling current translations")
|
||||
return fmt.Errorf("unmarshalling current translations: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -494,12 +492,12 @@ func writeStringsToFiles(e *state, output string) error {
|
|||
|
||||
c, err := json.MarshalIndent(currentTranslations, "", "\t")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshalling translations")
|
||||
return fmt.Errorf("marshalling translations: %w", err)
|
||||
}
|
||||
c = append(c, '\n')
|
||||
err = os.WriteFile(path, c, info.Mode())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "writing translation file")
|
||||
return fmt.Errorf("writing translation file: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf(" (%d translated, %d untranslated)\n", t, u)
|
||||
|
|
@ -512,12 +510,12 @@ func writeStringsToFiles(e *state, output string) error {
|
|||
|
||||
c, err := json.MarshalIndent(e.translations, "", "\t")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshalling translations")
|
||||
return fmt.Errorf("marshalling translations: %w", err)
|
||||
}
|
||||
path := filepath.Join(output, "strings.txt")
|
||||
err = os.WriteFile(path, c, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "writing translation file")
|
||||
return fmt.Errorf("writing translation file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -17,14 +17,16 @@ limitations under the License.
|
|||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
|
|
@ -74,14 +76,14 @@ func SaveToDir(images []string, cacheDir string, overwrite bool) error {
|
|||
out.WarningT("The image '{{.imageName}}' was not found; unable to add it to cache.", out.V{"imageName": image})
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "caching image %q", dst)
|
||||
return fmt.Errorf("caching image %q: %w", dst, err)
|
||||
}
|
||||
klog.Infof("save to tar file %s -> %s succeeded", image, dst)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
if err := g.Wait(); err != nil {
|
||||
return errors.Wrap(err, "caching images")
|
||||
return fmt.Errorf("caching images: %w", err)
|
||||
}
|
||||
klog.Infoln("Successfully saved all images to host disk.")
|
||||
return nil
|
||||
|
|
@ -98,7 +100,7 @@ func saveToTarFile(iname, rawDest string, overwrite bool) error {
|
|||
// OS-specific mangling of destination path
|
||||
dst, err := localpath.DstPath(rawDest)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting destination path")
|
||||
return fmt.Errorf("getting destination path: %w", err)
|
||||
}
|
||||
|
||||
spec := lock.PathMutexSpec(dst)
|
||||
|
|
@ -106,7 +108,7 @@ func saveToTarFile(iname, rawDest string, overwrite bool) error {
|
|||
klog.Infof("acquiring lock: %+v", spec)
|
||||
releaser, err := lock.Acquire(spec)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to acquire lock for %+v", spec)
|
||||
return fmt.Errorf("unable to acquire lock for %+v: %w", spec, err)
|
||||
}
|
||||
defer releaser.Release()
|
||||
|
||||
|
|
@ -116,16 +118,16 @@ func saveToTarFile(iname, rawDest string, overwrite bool) error {
|
|||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil {
|
||||
return errors.Wrapf(err, "making cache image directory: %s", dst)
|
||||
return fmt.Errorf("making cache image directory: %s: %w", dst, err)
|
||||
}
|
||||
|
||||
// use given short name
|
||||
ref, err := name.ParseReference(iname, name.WeakValidation)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing image ref name for %s", iname)
|
||||
return fmt.Errorf("parsing image ref name for %s: %w", iname, err)
|
||||
}
|
||||
if ref == nil {
|
||||
return errors.Wrapf(err, "nil reference for %s", iname)
|
||||
return fmt.Errorf("nil reference for %s: %w", iname, err)
|
||||
}
|
||||
|
||||
img, cname, err := retrieveImage(ref, iname)
|
||||
|
|
@ -134,17 +136,17 @@ func saveToTarFile(iname, rawDest string, overwrite bool) error {
|
|||
return errCacheImageDoesntExist
|
||||
}
|
||||
if img == nil {
|
||||
return errors.Wrapf(err, "nil image for %s", iname)
|
||||
return fmt.Errorf("nil image for %s: %w", iname, err)
|
||||
}
|
||||
|
||||
if cname != iname {
|
||||
// use new canonical name
|
||||
ref, err = name.ParseReference(cname, name.WeakValidation)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "parsing image ref name for %s", cname)
|
||||
return fmt.Errorf("parsing image ref name for %s: %w", cname, err)
|
||||
}
|
||||
if ref == nil {
|
||||
return errors.Wrapf(err, "nil reference for %s", cname)
|
||||
return fmt.Errorf("nil reference for %s: %w", cname, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,15 +178,15 @@ func writeImage(img v1.Image, dst string, ref name.Reference) error {
|
|||
|
||||
err = tarball.Write(ref, img, f)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
return fmt.Errorf("write: %w", err)
|
||||
}
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "close")
|
||||
return fmt.Errorf("close: %w", err)
|
||||
}
|
||||
err = os.Rename(f.Name(), dst)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "rename")
|
||||
return fmt.Errorf("rename: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue