separate
parent
18e9055fb4
commit
7e1a2a557b
|
@ -151,6 +151,11 @@ var dockerEnvCmd = &cobra.Command{
|
||||||
Shell: shell.ForceShell,
|
Shell: shell.ForceShell,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ok := isDockerActive(co.CP.Runner); !ok {
|
||||||
|
glog.Warningf("dockerd is not avtive will try to restart it...")
|
||||||
|
restartOrExitDaemon("docker", cname, co.CP.Runner)
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
port := constants.DockerDaemonPort
|
port := constants.DockerDaemonPort
|
||||||
if driver.NeedsPortForward(driverName) {
|
if driver.NeedsPortForward(driverName) {
|
||||||
|
@ -177,12 +182,7 @@ var dockerEnvCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := isDockerActive(co.CP.Runner); !ok {
|
out, err := tryDockerConnectivity("docker", ec)
|
||||||
glog.Warningf("dockerd is not avtive will try to restart it...")
|
|
||||||
restartOrExitDaemon("docker", cname, co.CP.Runner)
|
|
||||||
}
|
|
||||||
|
|
||||||
out, err := tryConnectivity("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") {
|
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)
|
glog.Infof("dockerd inside minkube is loaded with old certs with wrong IP. output: %s error: %v", string(out), err)
|
||||||
|
@ -273,8 +273,8 @@ func dockerEnvVarsList(ec DockerEnvConfig) []string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryConnectivity will try to connect to docker env from user's POV to detect the problem if it needs reset or not
|
// tryDockerConnectivity will try to connect to docker env from user's POV to detect the problem if it needs reset or not
|
||||||
func tryConnectivity(bin string, ec DockerEnvConfig) ([]byte, error) {
|
func tryDockerConnectivity(bin string, ec DockerEnvConfig) ([]byte, error) {
|
||||||
c := exec.Command(bin, "version", "--format={{.Server}}")
|
c := exec.Command(bin, "version", "--format={{.Server}}")
|
||||||
c.Env = append(os.Environ(), dockerEnvVarsList(ec)...)
|
c.Env = append(os.Environ(), dockerEnvVarsList(ec)...)
|
||||||
return c.CombinedOutput()
|
return c.CombinedOutput()
|
||||||
|
|
|
@ -122,22 +122,6 @@ var podmanEnvCmd = &cobra.Command{
|
||||||
restartOrExitDaemon("podman", cname, co.CP.Runner)
|
restartOrExitDaemon("podman", cname, co.CP.Runner)
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := tryConnectivity("docker", 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -160,6 +144,22 @@ 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,3 +217,18 @@ 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