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

service list cmd: display target port and name #6879

Merged

Conversation

prasadkatti
Copy link
Contributor

@prasadkatti prasadkatti commented Mar 4, 2020

Populate the target port in service list

fixes: #6860

Use port name for target port if provided. If not, use 'port'.
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#serviceport-v1-core

This is my first contribution to minikube. I am also fairly new to kubernetes. So please go easy on me. :)

Before

image

After

image

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

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

Hi @prasadkatti. 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 Mar 4, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: prasadkatti
To complete the pull request process, please assign tstromberg
You can assign the PR to them by writing /assign @tstromberg in a comment when ready.

The full list of commands accepted by this bot can be found 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

@prasadkatti prasadkatti force-pushed the populate_target_port_in_svc_list branch from eab12d9 to 720355b Compare March 4, 2020 06:35
@k8s-ci-robot k8s-ci-robot added 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 Mar 4, 2020
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@prasadkatti
Copy link
Contributor Author

/assign @tstromberg

@prasadkatti prasadkatti force-pushed the populate_target_port_in_svc_list branch from 720355b to 9f41fd4 Compare March 4, 2020 06:51
@medyagh
Copy link
Member

medyagh commented Mar 4, 2020

@prasadkatti can you please put before and after output in the PR description ?

Copy link
Member

@josedonizetti josedonizetti left a comment

Choose a reason for hiding this comment

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

@prasadkatti Thank you for this PR. I left a few comments.

@@ -196,6 +197,13 @@ func printURLsForService(c typed_core.CoreV1Interface, ip, service, namespace st
urls := []string{}
portNames := []string{}
for _, port := range svc.Spec.Ports {

if port.Name != "" {
m[port.TargetPort.IntVal] = port.Name
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the port name is useful by itself. I'd rather change to print something like name/port if name is available, if not only port.

Copy link
Member

@medyagh medyagh Mar 4, 2020

Choose a reason for hiding this comment

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

I agree ! if needed feel free to change the profile column name, to reflect the name/port

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 the review. I have pushed a change to address your feedback. I have added before/after images to issue description. The column name does need to be changed in my opinion. But I am not sure what would be the right name for the column.

serviceURLs := strings.Join(serviceURL.URLs, "\n")

// if we are running Docker on OSX we empty the internal service URLs
if runtime.GOOS == "darwin" && cfg.Driver == oci.Docker {
serviceURLs = ""
}

data = append(data, []string{serviceURL.Namespace, serviceURL.Name, "", serviceURLs})
data = append(data, []string{serviceURL.Namespace, serviceURL.Name, servicePortNames, serviceURLs})
Copy link
Member

@josedonizetti josedonizetti Mar 4, 2020

Choose a reason for hiding this comment

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

What we print for minikube service list must be consistent with what we print for minikube service <service-name>, so if we are printing name || port there, the same should be done here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both minikube service list and minikube service <service-name> eventually call printURLsForService which is where I am making these changes. So the results should be consistent. Maybe the variable name needs to change?

@medyagh
Copy link
Member

medyagh commented Mar 4, 2020

@prasadkatti welcome to the community of minikbue contributors :) happy to see your contribution !

@prasadkatti
Copy link
Contributor Author

@medyagh - Thanks. I am hoping to learn more about minikube/kubernetes through this process. I have added the before/after images that you requested to the issue description. The column header does need to change in my opinion, but I am not sure what I should change it to. Please provide suggestions.

@prasadkatti
Copy link
Contributor Author

Also, some tests are failing. I haven't quite figured that out yet. Are they failing because of these changes? I will need some help with that.

@medyagh
Copy link
Member

medyagh commented Mar 4, 2020

@prasadkatti unit tests are failing please make sure to run make test locally to see the error or checkout the https://github.com/kubernetes/minikube/pull/6879/checks?check_run_id=486144522

seems like we need to update our unit test

|-----------|----------------|-------------|--------------------------------|
| NAMESPACE |      NAME      | TARGET PORT |              URL               |
|-----------|----------------|-------------|--------------------------------|
| default   | mock-dashboard | 0 0         | http://127.0.0.1:1111          |
|           |                |             | http://127.0.0.1:2222          |
|-----------|----------------|-------------|--------------------------------|
|-----------|----------------|-------------|--------------------------------|
| NAMESPACE |      NAME      | TARGET PORT |              URL               |
|-----------|----------------|-------------|--------------------------------|
| default   | mock-dashboard | 0 0         | http://127.0.0.1:1111          |
|           |                |             | http://127.0.0.1:2222          |
|-----------|----------------|-------------|--------------------------------|
FAIL
coverage: 85.8% of statements
FAIL	k8s.io/minikube/pkg/minikube/service	2.576s
ok  	k8s.io/minikube/pkg/minikube/sshutil	0.417s	coverage: 100.0% of statements
ok  	k8s.io/minikube/pkg/minikube/storageclass	0.020s	coverage: 97.2% of statements
ok  	k8s.io/minikube/pkg/minikube/translate	0.015s	coverage: 11.9% of statements
ok  	k8s.io/minikube/pkg/minikube/tunnel	1.749s	coverage: 64.2% of statements
ok  	k8s.io/minikube/pkg/util	0.682s	coverage: 70.6% of statements
ok  	k8s.io/minikube/pkg/util/lock	0.005s	coverage: 18.2% of statements
ok  	k8s.io/minikube/pkg/util/retry	0.002s	co

@medyagh medyagh changed the title service list: populate target port wip: service list: populate target port Mar 4, 2020
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 4, 2020
@codecov-io
Copy link

Codecov Report

Merging #6879 into master will decrease coverage by 0.5%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6879      +/-   ##
=========================================
- Coverage    38.3%   37.8%   -0.51%     
=========================================
  Files         142     142              
  Lines        8740    8875     +135     
=========================================
+ Hits         3348    3355       +7     
- Misses       4971    5093     +122     
- Partials      421     427       +6
Impacted Files Coverage Δ
cmd/minikube/cmd/service_list.go 9.09% <0%> (-1.26%) ⬇️
pkg/minikube/service/service.go 77.24% <50%> (-0.59%) ⬇️
cmd/minikube/cmd/node_stop.go 15% <0%> (-8.08%) ⬇️
pkg/minikube/machine/status.go 42.42% <0%> (-6.07%) ⬇️
pkg/minikube/bootstrapper/bsutil/binaries.go 5.4% <0%> (-5.13%) ⬇️
pkg/minikube/driver/driver.go 54.76% <0%> (-2.74%) ⬇️
pkg/addons/addons.go 43.52% <0%> (-1.6%) ⬇️
cmd/minikube/cmd/config/open.go 11.86% <0%> (-1.35%) ⬇️
cmd/minikube/cmd/delete.go 23.55% <0%> (-1.34%) ⬇️
cmd/minikube/cmd/node_add.go 22.72% <0%> (-1.28%) ⬇️
... and 23 more

@prasadkatti
Copy link
Contributor Author

@medyagh - I have fixed the unit tests. I had to update the tests like you suspected.

@prasadkatti
Copy link
Contributor Author

Should I remove the wip: tag on this now?

@prasadkatti prasadkatti changed the title wip: service list: populate target port service list: populate target port Mar 10, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 10, 2020
@medyagh
Copy link
Member

medyagh commented Mar 12, 2020

Thanks @prasadkatti I will review this tommorow

@tstromberg
Copy link
Contributor

@medyagh - reminder to take a look at this PR when you get a chance

@prasadkatti
Copy link
Contributor Author

Any update on this? Do I need to fix anything else here?

@medyagh
Copy link
Member

medyagh commented Mar 28, 2020

/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 Mar 28, 2020
@medyagh
Copy link
Member

medyagh commented Mar 28, 2020

@prasadkatti thank you for your patience and sorry that took me so long to come back to this PR.
the changes look good to mne.
I will take another look after the integration tests restuls come back. if the results are good. we can merge this !

@minikube-pr-bot
Copy link

Error: running mkcmp: exit status 1

@medyagh
Copy link
Member

medyagh commented Mar 28, 2020

Thank you very much for this PR, this will improve minikube service command !

@medyagh medyagh merged commit da1d411 into kubernetes:master Mar 28, 2020
@medyagh medyagh changed the title service list: populate target port service list cmd: display target port in the list Mar 28, 2020
@medyagh medyagh changed the title service list cmd: display target port in the list service list cmd: display target port and name Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

service list: info target port not being populated
8 participants