remove podman-env restart
parent
7e1a2a557b
commit
82b79d6e8b
|
@ -122,7 +122,7 @@ func isDockerActive(r command.Runner) bool {
|
||||||
return sysinit.New(r).Active("docker")
|
return sysinit.New(r).Active("docker")
|
||||||
}
|
}
|
||||||
|
|
||||||
func restartOrExitDaemon(bin string, name string, runner command.Runner) {
|
func mustRestartDaemon(bin string, name string, runner command.Runner) {
|
||||||
if err := sysinit.New(runner).Restart(bin); err != nil {
|
if err := sysinit.New(runner).Restart(bin); err != nil {
|
||||||
exit.WithCodeT(exit.Unavailable, `The {{.service_name}} service within '{{.name}}' is not active`, out.V{"name": name, "service_name": bin})
|
exit.WithCodeT(exit.Unavailable, `The {{.service_name}} service within '{{.name}}' is not active`, out.V{"name": name, "service_name": bin})
|
||||||
}
|
}
|
||||||
|
@ -152,8 +152,8 @@ var dockerEnvCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := isDockerActive(co.CP.Runner); !ok {
|
if ok := isDockerActive(co.CP.Runner); !ok {
|
||||||
glog.Warningf("dockerd is not avtive will try to restart it...")
|
glog.Warningf("dockerd is not active will try to restart it...")
|
||||||
restartOrExitDaemon("docker", cname, co.CP.Runner)
|
mustRestartDaemon("docker", cname, co.CP.Runner)
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -184,16 +184,12 @@ var dockerEnvCmd = &cobra.Command{
|
||||||
|
|
||||||
out, err := tryDockerConnectivity("docker", ec)
|
out, err := tryDockerConnectivity("docker", ec)
|
||||||
if err != nil { // docker might be up but been loaded with wrong certs/config
|
if err != nil { // docker might be up but been loaded with wrong certs/config
|
||||||
if strings.Contains(err.Error(), "x509: certificate is valid") {
|
glog.Warningf("couldn't connect to docker inside minikube. output: %s error: %v", string(out), err)
|
||||||
glog.Infof("dockerd inside minkube is loaded with old certs with wrong IP. output: %s error: %v", string(out), err)
|
// to fix issues like this #8185
|
||||||
} else {
|
|
||||||
glog.Warningf("couldn't connect to docker inside minikube. output: %s error: %v", string(out), err)
|
|
||||||
}
|
|
||||||
// on minikube stop, or computer restart the IP might change.
|
|
||||||
// reloads the certs to prevent #8185
|
|
||||||
glog.Infof("will try to restart dockerd service...")
|
glog.Infof("will try to restart dockerd service...")
|
||||||
restartOrExitDaemon("docker", cname, co.CP.Runner)
|
mustRestartDaemon("docker", cname, co.CP.Runner)
|
||||||
// TODO: use kverify to wait for apisefver instead #8241
|
// TODO #8241: use kverify to wait for apisefver instead
|
||||||
|
// waiting for the basics like api-server to come up
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/drivers"
|
"github.com/docker/machine/libmachine/drivers"
|
||||||
"github.com/docker/machine/libmachine/ssh"
|
"github.com/docker/machine/libmachine/ssh"
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/minikube/pkg/minikube/command"
|
"k8s.io/minikube/pkg/minikube/command"
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
|
@ -117,11 +115,6 @@ var podmanEnvCmd = &cobra.Command{
|
||||||
exit.UsageT(`'none' driver does not support 'minikube podman-env' command`)
|
exit.UsageT(`'none' driver does not support 'minikube podman-env' command`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := isPodmanAvailable(co.CP.Runner); !ok {
|
|
||||||
glog.Warningf("podman service inside minikube is not active will try to restart it...")
|
|
||||||
restartOrExitDaemon("podman", cname, co.CP.Runner)
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := createExternalSSHClient(co.CP.Host.Driver)
|
client, err := createExternalSSHClient(co.CP.Host.Driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting ssh client", err)
|
exit.WithError("Error getting ssh client", err)
|
||||||
|
@ -144,22 +137,6 @@ var podmanEnvCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := tryPodmanConnectivity(ec)
|
|
||||||
if err != nil { // docker might be up but been loaded with wrong certs/config
|
|
||||||
if strings.Contains(err.Error(), "x509: certificate is valid") {
|
|
||||||
glog.Infof("dockerd inside minkube is loaded with old certs with wrong IP. output: %s error: %v", string(out), err)
|
|
||||||
} else {
|
|
||||||
glog.Warningf("couldn't connect to docker inside minikube. output: %s error: %v", string(out), err)
|
|
||||||
}
|
|
||||||
// on minikube stop, or computer restart the IP might change.
|
|
||||||
// reloads the certs to prevent #8185
|
|
||||||
glog.Infof("will try to restart dockerd service...")
|
|
||||||
restartOrExitDaemon("docker", cname, co.CP.Runner)
|
|
||||||
// temp fix we add Wait for apiserver
|
|
||||||
// TODO: use kverify to wait for apisefver instead #8241
|
|
||||||
time.Sleep(time.Second * 3)
|
|
||||||
}
|
|
||||||
|
|
||||||
if podmanUnset {
|
if podmanUnset {
|
||||||
if err := podmanUnsetScript(ec, os.Stdout); err != nil {
|
if err := podmanUnsetScript(ec, os.Stdout); err != nil {
|
||||||
exit.WithError("Error generating unset output", err)
|
exit.WithError("Error generating unset output", err)
|
||||||
|
@ -217,18 +194,3 @@ func init() {
|
||||||
podmanEnvCmd.Flags().StringVar(&shell.ForceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect")
|
podmanEnvCmd.Flags().StringVar(&shell.ForceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect")
|
||||||
podmanEnvCmd.Flags().BoolVarP(&podmanUnset, "unset", "u", false, "Unset variables instead of setting them")
|
podmanEnvCmd.Flags().BoolVarP(&podmanUnset, "unset", "u", false, "Unset variables instead of setting them")
|
||||||
}
|
}
|
||||||
|
|
||||||
// dpodmanEnvVarsList gets the necessary env variables to allow the use of minikube's podman daemon to be used in a exec.Command
|
|
||||||
func podmanEnvVarsList(ec PodmanEnvConfig) []string {
|
|
||||||
return []string{
|
|
||||||
fmt.Sprintf("%s=%s", constants.PodmanVarlinkBridgeEnv, podmanBridge(ec.client)),
|
|
||||||
fmt.Sprintf("%s=%s", constants.MinikubeActivePodmanEnv, ec.profile),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// tryPodmanConnectivity will try to connect to podman-env from user's POV to detect the problem if it needs reset or not
|
|
||||||
func tryPodmanConnectivity(ec PodmanEnvConfig) ([]byte, error) {
|
|
||||||
c := exec.Command("podman", "version", "--format={{.Server}}")
|
|
||||||
c.Env = append(os.Environ(), podmanEnvVarsList(ec)...)
|
|
||||||
return c.CombinedOutput()
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue