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

Correct unable to set apihost issue. #2463

Merged
merged 2 commits into from
Sep 14, 2017
Merged

Conversation

lzbj
Copy link
Contributor

@lzbj lzbj commented Jul 7, 2017

line 864 url.Parse caused failure.
Fixes #2411.

@lzbj lzbj mentioned this pull request Jul 7, 2017
@lzbj lzbj force-pushed the unable_set_apihost branch 2 times, most recently from db77c02 to 36ae998 Compare July 10, 2017 08:36
@@ -151,7 +151,7 @@ class WskBasicUsageTests
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
try {
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
val apihost = s"http://${WhiskProperties.getBaseControllerAddress()}"
val apihost = s"${WhiskProperties.getBaseControllerAddress()}"
Copy link
Member

Choose a reason for hiding this comment

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

@lzbj, need a test for setting the API host with and without a protocol.

Copy link
Member

Choose a reason for hiding this comment

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

@lzbj, also looks like the test failed because the server is expecting an http request instead of an https request.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the original error comes from the url.Parse(urlBase) function.

Copy link
Contributor Author

@lzbj lzbj Jul 11, 2017

Choose a reason for hiding this comment

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

Yes, correct, I'll update according to your comments. But When I change the "https" to "http", I got another deployment error, we should add "http" if the host not specified the protocol, right? @dubeejw

@@ -151,7 +151,7 @@ class WskBasicUsageTests
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
try {
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
val apihost = s"http://${WhiskProperties.getBaseControllerAddress()}"
val apihost = s"${WhiskProperties.getBaseControllerAddress()}"
Copy link
Member

Choose a reason for hiding this comment

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

@lzbj, also looks like the test failed because the server is expecting an http request instead of an https request.

@@ -151,7 +151,7 @@ class WskBasicUsageTests
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
try {
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
val apihost = s"http://${WhiskProperties.getBaseControllerAddress()}"
val apihost = s"${WhiskProperties.getBaseControllerAddress()}"
Copy link
Member

Choose a reason for hiding this comment

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

I believe the original error comes from the url.Parse(urlBase) function.

@@ -856,6 +856,10 @@ func getURLBase(host string, path string) (*url.URL, error) {
return nil, whiskErr
}

if !strings.HasPrefix(host, "http") {
host = "http://" + host
Copy link
Member

Choose a reason for hiding this comment

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

What if the OpenWhisk deployment only supports https?

Copy link
Member

Choose a reason for hiding this comment

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

I believe the error is thrown blow on line 864 url.Parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct, updated the code. If we can't avoid deployment using https, we can just add one test. do you have any suggestion we can add more tests?

@rabbah
Copy link
Member

rabbah commented Jul 13, 2017

The cli must support both - there's a test for http as well as https which is the nginx path.

@lzbj
Copy link
Contributor Author

lzbj commented Jul 14, 2017

Ok, thank you. Then now the test in WskBasicUsageTests is sufficient for the change, right?

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

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

LGTM

@rabbah rabbah added the cli label Jul 19, 2017
@@ -148,7 +148,7 @@ class WskBasicUsageTests
}
}

it should "show api build using http apihost" in {
it should "show api build using http apihost with protocol specified" in {
Copy link
Contributor

Choose a reason for hiding this comment

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

@lzbj - is another successful test needed that provides the api host without the protocol being provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can just add one http test, because the server expects http protocol, if we add another test without providing 'http', the test will fail. Do you have better idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is the area of code i was considering

+    if !strings.HasPrefix(host, "http") {
+        host = "https://" + host
+    }

so i was thinking an apihost setting with and without a http prefix should work. will a protocol-less apihost fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this line "I believe the error is thrown blow on line 864 url.Parse." will fail as @dubeejw comments.

@@ -841,6 +841,10 @@ func getURLBase(host string, path string) (*url.URL, error) {
return nil, whiskErr
}

if !strings.HasPrefix(host, "http") {
host = "https://" + host
Copy link
Member

Choose a reason for hiding this comment

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

Need a test for this.

@rabbah rabbah force-pushed the unable_set_apihost branch 2 times, most recently from c248c41 to 0b3cdeb Compare September 8, 2017 03:30
@rabbah
Copy link
Member

rabbah commented Sep 8, 2017

@mdeuser @dubeejw @lzbj i pushed a commit which adds tests.

@lzbj
Copy link
Contributor Author

lzbj commented Sep 8, 2017

@rabbah , thanks.

val apihost = s"$prefix$host"
withClue(apihost) {
val rr = wsk.cli(Seq("property", "set", "--apihost", apihost), env = env)
rr.stdout should not include regex("Application exited unexpectedly")
Copy link
Member

Choose a reason for hiding this comment

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

Errors are printed to stderr, so shouldn't need this check.

Copy link
Member

@dubee dubee left a comment

Choose a reason for hiding this comment

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

LGTM

@rabbah rabbah force-pushed the unable_set_apihost branch 2 times, most recently from 6943140 to dfe5cf8 Compare September 14, 2017 03:20
@rabbah
Copy link
Member

rabbah commented Sep 14, 2017

pg1/2055 🔵

@csantanapr csantanapr merged commit 5856485 into apache:master Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants