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

fix: quit minikube service when there is no available pods #15079

Merged
merged 5 commits into from
Jun 12, 2023

Conversation

ComradeProgrammer
Copy link
Member

@ComradeProgrammer ComradeProgrammer commented Oct 6, 2022

fixes #14592
When we try to run a deployment who is using a container which crashes immediately(thus no pods will be available), and then try to use minikube service to open a tunnel for it

Before:

minikube service hello-minikube
|-----------|----------------|-------------|---------------------------|
| NAMESPACE |      NAME      | TARGET PORT |            URL            |
|-----------|----------------|-------------|---------------------------|
| default   | hello-minikube |        8080 | http://192.168.49.2:31325 |
|-----------|----------------|-------------|---------------------------|
🏃  Starting tunnel for service hello-minikube.
|-----------|----------------|-------------|------------------------|
| NAMESPACE |      NAME      | TARGET PORT |          URL           |
|-----------|----------------|-------------|------------------------|
| default   | hello-minikube |             | http://127.0.0.1:62242 |
|-----------|----------------|-------------|------------------------|
🎉  Opening service default/hello-minikube in default browser...

service will be exposed, although it cannot be visited.

After

Now if the service has no running pods, output will be like this

wsl@win10pc:~/workspace/minikube-fork/out$ ./minikube service bad-node
|-----------|----------|-------------|---------------------------|
| NAMESPACE |   NAME   | TARGET PORT |            URL            |
|-----------|----------|-------------|---------------------------|
| default   | bad-node |        8080 | http://192.168.49.2:32262 |
|-----------|----------|-------------|---------------------------|

❌  Exiting due to SVC_TUNNEL_START: no valid pod for service bad-node found

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 6, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @ComradeProgrammer. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 6, 2022
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link

@guresonur guresonur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ComradeProgrammer
When there is a deployment has created these Pods, restartPolicy of the Deployment set to Always so the pod.Status.Phase would return Running, even in the case of there is a problem with Pod and it would still give URL and try to open web-browser.

So maybe checking the ContainerStatuses and readiness state might be helpful?

for _, containerStatus := range pod.Status.ContainerStatuses {
			if containerStatus.Ready == true {
				return nil
			}
		}

cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR, do u mind putting the before/after this PR in the description ?

@ComradeProgrammer
Copy link
Member Author

ComradeProgrammer commented Oct 13, 2022

thanks for the PR, do u mind putting the before/after this PR in the description ?

before/after has been added

cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
Copy link
Member

@spowelljr spowelljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a test be added to ensure this is working

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 17, 2022
@ComradeProgrammer
Copy link
Member Author

Could a test be added to ensure this is working

Thanks for the review, a test has been added, and I've run locally. it works

@spowelljr
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 17, 2022
@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@spowelljr
Copy link
Member

@ComradeProgrammer It looks like the tests are failing

@spowelljr spowelljr added the do-not-merge/failing-test Indicates that a PR should not merge because it has a failing test label Nov 18, 2022
@ComradeProgrammer
Copy link
Member Author

@ComradeProgrammer It looks like the tests are failing

I think this time it will work.

Sorry, silly bug. I forgot to write code to start minikube at the beginning of the test. Last time when I ran test locally before, I had a running cluster, that's why nothing wrong happened locally but test failed on the runner.

@spowelljr
Copy link
Member

@ComradeProgrammer Could you run make generate-docs to add the test to the documentation, thanks

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2023
@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

test/integration/functional_test.go Outdated Show resolved Hide resolved
test/integration/functional_test.go Outdated Show resolved Hide resolved
test/integration/functional_test.go Outdated Show resolved Hide resolved
pkg/minikube/service/service.go Outdated Show resolved Hide resolved
pkg/minikube/service/service.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
test/integration/functional_test.go Outdated Show resolved Hide resolved
@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com>
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15079) |
+----------------+----------+---------------------+
| minikube start | 53.9s    | 55.6s               |
| enable ingress | 29.8s    | 30.0s               |
+----------------+----------+---------------------+

Times for minikube ingress: 30.5s 29.4s 30.3s 29.0s 29.5s
Times for minikube (PR 15079) ingress: 29.5s 29.5s 29.5s 31.9s 29.9s

Times for minikube start: 53.4s 54.1s 53.5s 54.7s 53.7s
Times for minikube (PR 15079) start: 54.4s 61.1s 54.3s 53.4s 54.6s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15079) |
+----------------+----------+---------------------+
| minikube start | 25.9s    | 26.1s               |
| enable ingress | 21.0s    | 21.0s               |
+----------------+----------+---------------------+

Times for minikube start: 27.5s 23.2s 26.9s 26.2s 25.9s
Times for minikube (PR 15079) start: 26.6s 23.3s 26.7s 27.3s 26.3s

Times for minikube ingress: 21.0s 21.0s 21.0s 21.0s 21.0s
Times for minikube (PR 15079) ingress: 22.0s 20.5s 21.0s 20.5s 21.0s

docker driver with containerd runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15079) |
+-------------------+----------+---------------------+
| minikube start    | 25.0s    | 24.1s               |
| ⚠️  enable ingress | 32.0s    | 40.6s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube ingress: 47.5s 20.0s 31.0s 31.0s 30.5s
Times for minikube (PR 15079) ingress: 31.0s 31.5s 78.5s 31.0s 31.0s

Times for minikube (PR 15079) start: 25.4s 23.6s 21.7s 24.9s 25.1s
Times for minikube start: 24.5s 25.3s 25.3s 25.2s 24.6s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_Windows TestKicCustomSubnet (gopogh) 1.08 (chart)
Docker_Windows TestNoKubernetes/serial/StartNoArgs (gopogh) 3.26 (chart)
Docker_Windows TestStartStop/group/no-preload/serial/Pause (gopogh) 9.68 (chart)
Docker_Windows TestStartStop/group/old-k8s-version/serial/Pause (gopogh) 9.68 (chart)
Docker_Linux_crio TestFunctional/parallel/ImageCommands/ImageLoadDaemon (gopogh) 10.26 (chart)
Docker_Windows TestPause/serial/SecondStartNoReconfiguration (gopogh) 10.75 (chart)
Hyper-V_Windows TestPause/serial/SecondStartNoReconfiguration (gopogh) 14.00 (chart)

To see the flake rates of all tests by environment, click here.

pkg/minikube/reason/reason.go Outdated Show resolved Hide resolved
test/integration/functional_test.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
ComradeProgrammer and others added 3 commits June 10, 2023 21:43
Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com>
Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com>
Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com>
Copy link
Member

@spowelljr spowelljr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good, thanks!

@spowelljr spowelljr merged commit 64df06f into kubernetes:master Jun 12, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ComradeProgrammer, spowelljr

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/failing-test Indicates that a PR should not merge because it has a failing test ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minikube service command should not try to open a URL for a failing pod
8 participants