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

Add ability to get json for "minikube service list" #15831

Merged
merged 5 commits into from Feb 22, 2023

Conversation

OmSaran
Copy link
Contributor

@OmSaran OmSaran commented Feb 11, 2023

fixes #15827

Before:

$ minikube service list -o=json
Error: unknown shorthand flag: 'o' in -o=json
See 'minikube service list --help' for usage.

After:

$ ./out/minikube service list -o=json
[{"Namespace":"default","Name":"kubernetes","URLs":[],"PortNames":[]},{"Namespace":"kube-system","Name":"kube-dns","URLs":[],"PortNames":[]}]

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 11, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: OmSaran / name: Om Saran (f0e2e38)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Feb 11, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @OmSaran!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 11, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @OmSaran. 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 11, 2023
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

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 you also add a simple test to

// validateServiceCmd asserts basic "service" command functionality
func validateServiceCmd(ctx context.Context, t *testing.T, profile string) {

Similar to

// docs: Run `minikube profile list -o JSON` and make sure the profiles are correctly listed as JSON output
t.Run("profile_json_output", func(t *testing.T) {

Comment on lines 54 to 59
switch output {
case "table":
printServicesTable(serviceURLs, co)
case "json":
printServicesJSON(serviceURLs)
}
Copy link
Member

Choose a reason for hiding this comment

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

There should be a default case that outputs something like:

exit.Message(reason.Usage, fmt.Sprintf("invalid output format: %s. Valid values: 'table', 'json'", output))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this, fixed it!

@medyagh
Copy link
Member

medyagh commented Feb 15, 2023

@OmSaran do you have any questions on how to add integration test?

@OmSaran
Copy link
Contributor Author

OmSaran commented Feb 15, 2023

Could you also add a simple test to

// validateServiceCmd asserts basic "service" command functionality
func validateServiceCmd(ctx context.Context, t *testing.T, profile string) {

Similar to

// docs: Run `minikube profile list -o JSON` and make sure the profiles are correctly listed as JSON output
t.Run("profile_json_output", func(t *testing.T) {

Done! Please take a look

@OmSaran
Copy link
Contributor Author

OmSaran commented Feb 15, 2023

@OmSaran do you have any questions on how to add integration test?

I took a stab at it, let me know if this looks okay!

@OmSaran OmSaran requested review from spowelljr and removed request for afbjorklund February 15, 2023 21:46
@medyagh
Copy link
Member

medyagh commented Feb 16, 2023

/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 Feb 16, 2023
@medyagh
Copy link
Member

medyagh commented Feb 16, 2023

@OmSaran please check the failed test https://github.com/kubernetes/minikube/actions/runs/4188409014/jobs/7262233741

to be clear we dont really need to do a full Service test again there (such as deploying a new service) we could just ensure the service list -o=json is a valid json and does have the service we expect there in json

@medyagh
Copy link
Member

medyagh commented Feb 16, 2023

@OmSaran you can run the functional tests on your own machine using "make functional"

@OmSaran
Copy link
Contributor Author

OmSaran commented Feb 16, 2023

@OmSaran you can run the functional tests on your own machine using "make functional"

This time I tested it using a linux machine and it was successful. Thanks!

<truncated>
--- PASS: TestFunctional/parallel/ServiceCmd (30.40s)
            --- PASS: TestFunctional/parallel/ServiceCmd/service_json_output (2.33s)
<truncated>

Previously it was not working on my local MacOS machine as it was getting hung in ServiceCmdConnect test (so I had a few hacks to test it which included testing it with hardcoded profile and thus didn't catch the failure scenario in the build).

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15831) |
+----------------+----------+---------------------+
| minikube start | 53.8s    | 54.4s               |
| enable ingress | 24.7s    | 25.8s               |
+----------------+----------+---------------------+

Times for minikube start: 54.1s 50.5s 55.2s 51.7s 57.3s
Times for minikube (PR 15831) start: 54.7s 53.6s 54.5s 54.6s 54.7s

Times for minikube ingress: 24.7s 25.2s 25.3s 23.8s 24.7s
Times for minikube (PR 15831) ingress: 27.2s 23.7s 24.7s 28.3s 25.2s

docker driver with docker runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15831) |
+-------------------+----------+---------------------+
| minikube start    | 27.2s    | 26.9s               |
| ⚠️  enable ingress | 21.6s    | 33.5s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube start: 26.3s 27.8s 27.6s 26.5s 27.9s
Times for minikube (PR 15831) start: 27.4s 26.4s 27.2s 26.4s 27.1s

Times for minikube ingress: 22.1s 22.1s 20.1s 21.6s 22.1s
Times for minikube (PR 15831) ingress: 83.6s 20.1s 20.1s 23.6s 20.1s

docker driver with containerd runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15831) |
+-------------------+----------+---------------------+
| minikube start    | 22.1s    | 22.2s               |
| ⚠️  enable ingress | 26.8s    | 35.4s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube ingress: 28.6s 19.6s 32.6s 20.6s 32.6s
Times for minikube (PR 15831) ingress: 32.6s 47.6s 32.6s 31.6s 32.6s

Times for minikube start: 22.8s 22.3s 22.0s 21.6s 21.8s
Times for minikube (PR 15831) start: 22.3s 22.0s 21.9s 22.9s 21.9s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_Linux TestMultiNode/serial/DeployApp2Nodes (gopogh) 0.62 (chart)
Docker_Linux TestMultiNode/serial/PingHostFrom2Pods (gopogh) 0.62 (chart)
Docker_macOS TestMultiNode/serial/DeployApp2Nodes (gopogh) 1.97 (chart)
Docker_macOS TestMultiNode/serial/PingHostFrom2Pods (gopogh) 1.97 (chart)
KVM_Linux TestPause/serial/SecondStartNoReconfiguration (gopogh) 9.43 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressDNSAddonActivation (gopogh) 98.68 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddonActivation (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddons (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/StartLegacyK8sCluster (gopogh) 100.00 (chart)
Docker_macOS TestKubernetesUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestMissingContainerUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestRunningBinaryUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/AddonExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/DeployApp (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/EnableAddonWhileActive (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/FirstStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/SecondStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/UserAppExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStoppedBinaryUpgrade/Upgrade (gopogh) 100.00 (chart)
KVM_Linux_containerd TestPreload (gopogh) 100.00 (chart)

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

@kubernetes kubernetes deleted a comment from minikube-pr-bot Feb 16, 2023
@kubernetes kubernetes deleted a comment from minikube-pr-bot Feb 16, 2023
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.

Can you also run make generate-docs to update the website documentation with the new flag, thanks

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
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 20, 2023
@OmSaran
Copy link
Contributor Author

OmSaran commented Feb 20, 2023

Can you also run make generate-docs to update the website documentation with the new flag, thanks

I did, but I see some other changes too which I did not intend but was a consequence of make generate-docs e.g., here. Would be great if you could let me know if I should fix it and guide me on how to fix it.

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime
error collecting results for kvm2 driver: timing run 3 with minikube (PR 15831): timing cmd: [/home/jenkins/.minikube/minikube-binaries/15831/minikube start --driver=kvm2 --container-runtime=docker]: waiting for minikube: exit status 90
docker driver with docker runtime
error downloading artifacts: artifact download start: exit status 81docker driver with containerd runtime
error downloading artifacts: artifact download start: exit status 81

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
KVM_Linux TestFunctional/parallel/MountCmd/specific-port (gopogh) 0.00 (chart)
Hyperkit_macOS TestRunningBinaryUpgrade (gopogh) 10.27 (chart)
Docker_Linux TestMultiNode/serial/DeployApp2Nodes (gopogh) 32.53 (chart)
Docker_Linux TestMultiNode/serial/PingHostFrom2Pods (gopogh) 32.53 (chart)
Docker_macOS TestMultiNode/serial/DeployApp2Nodes (gopogh) 33.76 (chart)
Docker_macOS TestMultiNode/serial/PingHostFrom2Pods (gopogh) 33.76 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressDNSAddonActivation (gopogh) 99.36 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddonActivation (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddons (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/StartLegacyK8sCluster (gopogh) 100.00 (chart)
Docker_macOS TestKubernetesUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestMissingContainerUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestRunningBinaryUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/AddonExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/DeployApp (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/EnableAddonWhileActive (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/FirstStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/SecondStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/UserAppExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStoppedBinaryUpgrade/Upgrade (gopogh) 100.00 (chart)
KVM_Linux_containerd TestPreload (gopogh) 100.00 (chart)

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

@spowelljr
Copy link
Member

Can you also run make generate-docs to update the website documentation with the new flag, thanks

I did, but I see some other changes too which I did not intend but was a consequence of make generate-docs e.g., here. Would be great if you could let me know if I should fix it and guide me on how to fix it.

That's just a change from a previous PR that didn't get the command run on it, it's fine to include it.

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.

My only concern is that if using Docker on macOS we strip out the service URLs for table output but not for JSON which will cause a discrepancy between the two outputs.

To solve this we can loop through the services before the switch statement to remove the URLs so the outputs match.

@OmSaran
Copy link
Contributor Author

OmSaran commented Feb 22, 2023

My only concern is that if using Docker on macOS we strip out the service URLs for table output but not for JSON which will cause a discrepancy between the two outputs.

To solve this we can loop through the services before the switch statement to remove the URLs so the outputs match.

I fixed this in the new commit, please take a look.

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15831) |
+----------------+----------+---------------------+
| minikube start | 55.4s    | 53.3s               |
| enable ingress | 27.2s    | 26.4s               |
+----------------+----------+---------------------+

Times for minikube start: 55.6s 56.1s 54.8s 55.3s 55.0s
Times for minikube (PR 15831) start: 55.2s 50.7s 53.3s 56.1s 51.3s

Times for minikube ingress: 26.2s 24.3s 28.7s 29.3s 27.7s
Times for minikube (PR 15831) ingress: 24.2s 28.7s 28.8s 25.7s 24.8s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15831) |
+----------------+----------+---------------------+
| minikube start | 27.5s    | 27.6s               |
| enable ingress | 22.3s    | 22.0s               |
+----------------+----------+---------------------+

Times for minikube start: 28.4s 27.0s 26.9s 27.8s 27.4s
Times for minikube (PR 15831) start: 27.4s 27.7s 27.9s 28.3s 26.8s

Times for minikube ingress: 22.1s 23.1s 21.1s 22.2s 23.1s
Times for minikube (PR 15831) ingress: 22.1s 22.1s 21.1s 23.6s 21.1s

docker driver with containerd runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15831) |
+-------------------+----------+---------------------+
| minikube start    | 22.2s    | 22.5s               |
| ⚠️  enable ingress | 25.0s    | 35.2s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube start: 21.5s 22.8s 22.9s 21.7s 22.3s
Times for minikube (PR 15831) start: 22.2s 22.1s 23.4s 23.1s 21.6s

Times for minikube ingress: 32.6s 21.6s 19.6s 19.6s 31.6s
Times for minikube (PR 15831) ingress: 32.6s 48.6s 31.8s 32.6s 30.6s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_Windows TestRunningBinaryUpgrade (gopogh) 0.00 (chart)
Hyperkit_macOS TestFunctional/parallel/MySQL (gopogh) 1.35 (chart)
Hyperkit_macOS TestFunctional/parallel/DashboardCmd (gopogh) 2.03 (chart)
KVM_Linux_containerd TestJSONOutput/stop/parallel/DistinctCurrentSteps (gopogh) 7.27 (chart)
KVM_Linux_containerd TestJSONOutput/stop/parallel/IncreasingCurrentSteps (gopogh) 7.27 (chart)
Docker_Linux TestMultiNode/serial/DeployApp2Nodes (gopogh) 43.29 (chart)
Docker_Linux TestMultiNode/serial/PingHostFrom2Pods (gopogh) 43.29 (chart)
Docker_macOS TestMultiNode/serial/DeployApp2Nodes (gopogh) 44.23 (chart)
Docker_macOS TestMultiNode/serial/PingHostFrom2Pods (gopogh) 44.23 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressDNSAddonActivation (gopogh) 99.36 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddonActivation (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/serial/ValidateIngressAddons (gopogh) 100.00 (chart)
Docker_macOS TestIngressAddonLegacy/StartLegacyK8sCluster (gopogh) 100.00 (chart)
Docker_macOS TestKubernetesUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestMissingContainerUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestRunningBinaryUpgrade (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/AddonExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/DeployApp (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/EnableAddonWhileActive (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/FirstStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/SecondStart (gopogh) 100.00 (chart)
Docker_macOS TestStartStop/group/old-k8s-version/serial/UserAppExistsAfterStop (gopogh) 100.00 (chart)
Docker_macOS TestStoppedBinaryUpgrade/Upgrade (gopogh) 100.00 (chart)
Docker_Windows TestFunctional/parallel/ServiceCmd (gopogh) 100.00 (chart)
KVM_Linux_containerd TestPreload (gopogh) 100.00 (chart)

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

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.

Looks good to me, thanks for your PR!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: OmSaran, 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 Feb 22, 2023
@spowelljr spowelljr merged commit 6cc5ddc into kubernetes:master Feb 22, 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. 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.

add ability to get json for "minikube sevice list"
6 participants