Skip to content
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

minikube service opens in browser when it should not #5789

Closed
retracile opened this issue Oct 30, 2019 · 16 comments · Fixed by #5790
Closed

minikube service opens in browser when it should not #5789

retracile opened this issue Oct 30, 2019 · 16 comments · Fixed by #5790
Assignees
Labels
co/service issues related to the service feature kind/bug Categorizes issue or PR as related to a bug.

Comments

@retracile
Copy link

The exact command to reproduce the issue:

minikube service --namespace mynamespace --url mynodeportservice

The full output of the command that failed:

In versions of minikube through 1.3.1, this output the service URL to stdout, and did not open the URL in the default browser. In 1.5.1, it outputs the URL and the "🎉 Opening kubernetes service ..." message to stdout, and it opens in the default browser.

With --url=false, it does not open in the browser, but now it outputs an ascii-art table instead of the plain URL.
With --url=true, it behaves the same as with --url.

Based on finding #5699, I tried using --format="{{ .IP }}". That leads to even greater insanity... it emits the message about opening the service in the default browser, but then fails to do so because it tries to open a file in the current directory matching the IP address, and errors out.

Please restore the older behavior so scripts can get the URL for a service, and fix --format to not try to open the resulting string in the default browser.

The output of the minikube logs command:

The operating system version:
Mojave
minikube 1.5.1 installed via homebrew

@tstromberg
Copy link
Contributor

This sounds like a regression, possibly caused by #5718. Perhaps the urlMode logic got inverted?

/cc @nanikjava

@tstromberg tstromberg added the co/service issues related to the service feature label Oct 30, 2019
@tstromberg tstromberg self-assigned this Oct 30, 2019
@tstromberg tstromberg added the kind/bug Categorizes issue or PR as related to a bug. label Oct 30, 2019
@retracile
Copy link
Author

Looks like the logic moved from pkg/minikube/servcice/service.go to cmd/minikube/cmd/service.go between 1.3.1 and 1.5.1.
The logic in the command code is only looking at the length of urlString list to determine if it should open the browser, and is not considering the value of serviceURLMode.

@retracile
Copy link
Author

This might improve matters; haven't tried it yet

--- a/cmd/minikube/cmd/service.go
+++ b/cmd/minikube/cmd/service.go
@@ -82,7 +82,7 @@ var serviceCmd = &cobra.Command{
                        exit.WithError("Error opening service", err)
                }

-               if len(urlString) != 0 {
+               if !serviceURLMode && len(urlString) != 0 {
                        out.T(out.Celebrate, "Opening kubernetes service  {{.namespace_name}}/{{.service_name}} in default browser...", out.V{"namespace_name": namespace, "service_name": svc})

                        for _, url := range urlString {

@tstromberg
Copy link
Contributor

@retracile - Thanks, I'm working on a PR now with an integration test to avoid future similar breakage.

This definitely revealed a short-coming in our testing.

@retracile
Copy link
Author

Cool, thanks. :)
Also, the out.T message has two spaces between "service" and "{{"; should probably only have one.

@retracile
Copy link
Author

A quick local test shows that change fixes it for me, and --url --format "{{.IP}}" also works. :)

@tstromberg
Copy link
Contributor

tstromberg commented Oct 30, 2019

@retracile - Do you mind checking if #5790 looks good to you?

You can test it on macOS by using:

curl -LO https://storage.googleapis.com/minikube-builds/5790/minikube-darwin-amd64 
chmod u+x minikube-darwin-amd64
./minikube-darwin-amd64 service <flags>

@retracile
Copy link
Author

retracile commented Oct 30, 2019

There's no newline in the --url output, but there was in v1.5.0

Tangent: Under some situations I'm also seeing a * prefix on the output... this is very close to when the service is created, and I've seen that in older versions as well. I have not found a way to consistently reproduce that, so hadn't reported it. I haven't seen anything in the docs to indicate what that might be.

@tstromberg
Copy link
Contributor

The newline seemed incorrect to me, so I removed it out. I could preserve if it it's useful.

What command are you you seeing the * prefix?

@retracile
Copy link
Author

*NIX commands generally include the newline at the end; otherwise you wind up with your shell prompt tacked on the end of the output (when using it interactively). When using it within a script, it works either way.

@tstromberg
Copy link
Contributor

tstromberg commented Oct 30, 2019 via email

@retracile
Copy link
Author

For the * prefix, that's a separate issue, and dates way back. I see it when running the same command discussed here, but it appears to only happen for a brief period after the service is created... brief enough that I don't think I've ever managed to reproduce it outside of automated scripting. Maybe it happens in the time between the service being created and it being ready? Or something? ... I'm guessing there.

Regardless, it's a separate issue from this one.

@tstromberg
Copy link
Contributor

@retracile - Regardless, it sounds wrong. If you know of a way to reproduce it, let me know.

The asterisk is likely caused by a call to out.T() rather than the raw equivalent out.String(). I removed the calls I saw, but there may be others.

@retracile
Copy link
Author

out.T() vs out.String() is a useful clue; maybe I can track it down at some point. Thanks.

@tstromberg
Copy link
Contributor

Reopening until we release v1.5.2 containing this fix (tomorrow).

@tstromberg
Copy link
Contributor

Fixed in v1.5.2. Thank you for reporting this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/service issues related to the service feature kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants