-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-env: restart dockerd inside minikube on failure #8239
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: medyagh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report
@@ Coverage Diff @@
## master #8239 +/- ##
==========================================
- Coverage 34.48% 34.38% -0.10%
==========================================
Files 147 147
Lines 9418 9448 +30
==========================================
+ Hits 3248 3249 +1
- Misses 5771 5800 +29
Partials 399 399
|
cmd/minikube/cmd/docker-env.go
Outdated
@@ -138,6 +139,12 @@ var dockerEnvCmd = &cobra.Command{ | |||
out.V{"runtime": co.Config.KubernetesConfig.ContainerRuntime}) | |||
} | |||
|
|||
// on minikube stop, or computer restart the IP might change. | |||
// reloads the certs to prevent #8185 | |||
if err := sysinit.New(co.CP.Runner).Restart("docker"); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right place to restart Docker, mostly because it is very surprising behavior. If you really must restart within docker-env
calls, please update the help documentation accordingly.
My preference would be to see this restart done elsewhere, such as fix.go
or provision.go
:
provision
already restarts Docker if the systemd configuration has changed.- folks may be trying to access the docker daemon outside of the
docker-env
command
One thought: if you include the IP address in the Docker config template, it will magically restart if the IP or Docker configuration changes. We could also do this more explicitly, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this PR since this review, please take another look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in #8235, it is getting very hard to debug all these auto-restart functions
Travis tests have failedHey @medyagh, 1st Buildmake test
2nd Buildmake test
3rd Buildmake
TravisBuddy Request Identifier: c8e33bb0-9bc1-11ea-9438-0b74518d636c |
I agree that this behaviour is surprising. I was OK with starting dockerd if running I don't think docker-machine has this issue, because the daemon is normally started with the VM and the certificates are regenerated by the provisioner when it starts up. It only warns about the address (minikube ip) being changed:
Then there is I think the main reason we need this in minikube is because of 5cd7660 That's were we hard-coded the Provisioner and removed ConfigureAuth: - glog.Infof("Detecting provisioner ...")
- provisioner, err := provision.DetectProvisioner(h.Driver)
- if err != nil {
- return h, errors.Wrap(err, "detecting provisioner") - glog.Infof("Configuring auth for driver %s ...", h.Driver.DriverName())
- if err := h.ConfigureAuth(); err != nil {
- return h, &retry.RetriableError{Err: errors.Wrap(err, "Error configuring auth on host")}
- } This is also causing problems with some of my other later experiments, |
so the problem is, when you reconfigureAuth (that was refactored out of the code by thomas) it takes 5-6 times on each start (un-needed tax on minikube start) that is like we test the docker-env before returning and then restart if there is something wrong with docker. another thing that worth noting here is, docker does not need new Certs, it already does have Certs but it has loaded the wrong one ! ( I think this is because we Enable the docker-service in the kic base image for a faster start, so on first second it picks up the Old Certs and would hold on to them till we restart docker) |
Unless I am missing something, the IP only changes if |
cmd/minikube/cmd/podman-env.go
Outdated
// 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a cut and paste error: there is no docker daemon to restart within podman.
cmd/minikube/cmd/podman-env.go
Outdated
@@ -117,7 +118,8 @@ var podmanEnvCmd = &cobra.Command{ | |||
} | |||
|
|||
if ok := isPodmanAvailable(co.CP.Runner); !ok { | |||
exit.WithCodeT(exit.Unavailable, `The podman service within '{{.cluster}}' is not active`, out.V{"cluster": cname}) | |||
glog.Warningf("podman service inside minikube is not active will try to restart it...") | |||
restartOrExitDaemon("podman", cname, co.CP.Runner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no podman daemon
cmd/minikube/cmd/docker-env.go
Outdated
@@ -119,6 +122,12 @@ func isDockerActive(r command.Runner) bool { | |||
return sysinit.New(r).Active("docker") | |||
} | |||
|
|||
func restartOrExitDaemon(bin string, name string, runner command.Runner) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: For idiomatic go, functions which may cause an exit should be named something like mustRestartDocker
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I like that this PR documents the problem that is trying to be solved, but what is missing is a mention of why this is the best way to fix it. |
Travis tests have failedHey @medyagh, 1st Buildmake test
TravisBuddy Request Identifier: d7921600-9f8a-11ea-a34f-dd9ab62511aa |
cmd/minikube/cmd/docker-env.go
Outdated
mustRestartDocker(cname, co.CP.Runner) | ||
// TODO #8241: use kverify to wait for apisefver instead | ||
// waiting for the basics like api-server to come up | ||
time.Sleep(time.Second * 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this sleep until it can be proved that this is helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, but I am sure ppl will run into this, specially people who use this as part of another tool chain unvisible to the user
/ok-to-test |
0ce9881
to
6ff8c9a
Compare
kvm2 Driver Times for Minikube (PR 8239): [64.05310125000001 65.99178446799999 67.524245977] Averages Time Per Log
docker Driver Times for Minikube (PR 8239): [27.127987598999997 26.390889912 25.901410171000002] Averages Time Per Log
|
Travis tests have failedHey @medyagh, 1st Buildmake test
TravisBuddy Request Identifier: 7d274970-9f9d-11ea-a34f-dd9ab62511aa |
Before this PR when running docker-env, if docker service is not running we exit with error,
for example if minikube IP changes, the docker inside minikube needs to be restart to pick up the certs that have the new IP added to them.
closes #8185
This PR is meant for the last effort, when user reaches out to docker-env, the root cause can be fixed by a different PR. that will be for another release.
Before this PR: docker env when IP changed after minikube start
After this PR: docker env when IP changed after minikube start