-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
db77c02
to
36ae998
Compare
@@ -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()}" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()}" |
There was a problem hiding this comment.
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()}" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
The cli must support both - there's a test for http as well as https which is the nginx path. |
Ok, thank you. Then now the test in WskBasicUsageTests is sufficient for the change, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
c248c41
to
0b3cdeb
Compare
@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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
6943140
to
dfe5cf8
Compare
pg1/2055 🔵 |
line 864 url.Parse caused failure.
Fixes #2411.