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 support for url describe command #2694

Merged

Conversation

jichenjc
Copy link
Contributor

@jichenjc jichenjc commented Mar 10, 2020

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind code-refactoring

What does does this PR do / why we need it:

implemented this: I certainly can do further change on the output format, just submit
this for some comments

[root@xyimgr77 frontend]# ../odo url list
Found the following URLs for component ubi-frontend-gmhz in application app:
NAME                       STATE          URL     PORT
ubi-frontend-gmhz-8080     Not Pushed     ://     8080

There are local changes. Please run 'odo push'.
[root@xyimgr77 frontend]# ../odo url describe
 ✗  url  not found
[root@xyimgr77 frontend]# ../odo url describe abc
 ✗  url abc not found
[root@xyimgr77 frontend]# ../odo url describe ubi-frontend-gmhz-8080
NAME                       STATE          URL     PORT
ubi-frontend-gmhz-8080     Not Pushed     ://     8080

There are local changes. Please run 'odo push'.
[root@xyimgr77 frontend]#

Which issue(s) this PR fixes:

Fixes #?

How to test changes / Special notes to the reviewer:

@openshift-ci-robot
Copy link
Collaborator

Hi @jichenjc. Thanks for your PR.

I'm waiting for a openshift 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.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. Required by Prow. size/L labels Mar 10, 2020
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Mar 10, 2020
@kadel
Copy link
Member

kadel commented Mar 11, 2020

/ok-to-test

@openshift-ci-robot openshift-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. Required by Prow. labels Mar 11, 2020
@mik-dass
Copy link
Contributor

@jichenjc Thanks for the PR. Please edit the description and link the issue with this PR. Also please add some steps for testing the PR.

pkg/url/url.go Outdated Show resolved Hide resolved
Comment on lines 61 to 62
urls, err := url.List(o.Client, o.localConfigInfo, o.Component(), o.Application)
if err != nil {
return err
}
u, err := urls.Get(o.url)
if err != nil {
return err
}
Copy link
Contributor

@mik-dass mik-dass Mar 12, 2020

Choose a reason for hiding this comment

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

Since url describe can take only one URL name as a parameter input, I don't think we need url.List() here. We have faced slowness because of listing when we didn't need it. Please write a generic Get function for URL and use the client to make a get call for a route. Also to find the state, please use the local Config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it , will double check how to do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mik-dass
um.. after double check , seems we have something like
clusterURL := getMachineReadableFormat(r)
which means we can't search in etcd directly, we need get back the data then do some transform and
this of course need list ,

I can change the function to Get() the compare in the new function but still need list
so don't know how much improvement we get can... so, still a O(n) search , not O(1)

Copy link
Contributor

Choose a reason for hiding this comment

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

No you don't need a list. First write getRoute() function in occlient.go like https://github.com/openshift/odo/blob/master/pkg/occlient/occlient.go#L484 which returns the found route. Then write a Get() (don't use the existing one, it requires a list) function, call the getRoute() in occlient.go and transform the returned route to machine readable format using getMachineReadableFormat().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, get your point, I will try the way you suggested, thanks!

@@ -136,7 +136,7 @@ func PrintComponentInfo(client *occlient.Client, currentComponentName string, co

// Gather the output
for _, componentURL := range componentDesc.Spec.URL {
url := urls.Get(componentURL)
url, _ := urls.Get(componentURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't ignore the error. If the function returns a error, this might cause a panic as the returned URL will be empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it , thanks

@mik-dass
Copy link
Contributor

Also please add some integration test for this feature

@jichenjc jichenjc changed the title Add support for url describe command WIP: Add support for url describe command Mar 13, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Mar 13, 2020
@jichenjc
Copy link
Contributor Author

/retest

@jichenjc jichenjc force-pushed the add_describe_url branch 2 times, most recently from c33e659 to 31ee7fa Compare March 16, 2020 09:54
@codecov
Copy link

codecov bot commented Mar 16, 2020

Codecov Report

Merging #2694 into master will increase coverage by 0.29%.
The diff coverage is 18.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2694      +/-   ##
==========================================
+ Coverage   43.13%   43.43%   +0.29%     
==========================================
  Files          77       86       +9     
  Lines        7314     7978     +664     
==========================================
+ Hits         3155     3465     +310     
- Misses       3855     4173     +318     
- Partials      304      340      +36
Impacted Files Coverage Δ
pkg/url/url.go 39.61% <0%> (-6.61%) ⬇️
pkg/occlient/occlient.go 52.55% <100%> (+2.95%) ⬆️
pkg/odo/cli/catalog/util/util.go 40.47% <0%> (-18.15%) ⬇️
pkg/kclient/deployments.go 89.65% <0%> (-10.35%) ⬇️
pkg/kclient/generators.go 91.25% <0%> (-8.75%) ⬇️
pkg/kclient/kclient.go 26.92% <0%> (-3.52%) ⬇️
pkg/catalog/catalog.go 51.77% <0%> (-2.19%) ⬇️
pkg/kclient/volumes.go 93.22% <0%> (-1.66%) ⬇️
pkg/util/util.go 65.73% <0%> (-0.93%) ⬇️
pkg/kclient/pods.go 41.42% <0%> (-0.61%) ⬇️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e6116a...8a39bd6. Read the comment docs.

@jichenjc jichenjc force-pushed the add_describe_url branch 3 times, most recently from 562ff77 to 95cceb4 Compare March 18, 2020 02:12
@jichenjc jichenjc changed the title WIP: Add support for url describe command Add support for url describe command Mar 18, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Mar 18, 2020
pkg/url/url.go Outdated Show resolved Hide resolved
pkg/url/url.go Outdated Show resolved Hide resolved
pkg/url/url.go Outdated Show resolved Hide resolved
@@ -88,6 +88,21 @@ var _ = Describe("odo url command tests", func() {
})
})

Context("Describing urls", func() {
It("should describe appropriate URLs and push message", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add some more cases with the various pushed states or maybe even add them here itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

pkg/url/url.go Outdated Show resolved Hide resolved
@kadel
Copy link
Member

kadel commented Mar 20, 2020

This might not be that useful right now, as it is not providing any additional information compared to odo url list but I can see that in the future odo can provide more detailed information about url.

👍
/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Mar 20, 2020
@amitkrout
Copy link
Contributor

Integration test looks good to me
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 21, 2020
@openshift-merge-robot openshift-merge-robot merged commit fcd770f into redhat-developer:master Mar 21, 2020
@rm3l rm3l added estimated-size/L (20-40) Rough sizing for Epics. About 2 sprints of work for a person. and removed size/L labels Jun 18, 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. Required by Prow. estimated-size/L (20-40) Rough sizing for Epics. About 2 sprints of work for a person. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation lgtm Indicates that a PR is ready to be merged. Required by Prow. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants