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

Unable to create request URL, because OpenWhisk API host is missing #43

Open
tleyden opened this issue Nov 4, 2017 · 14 comments
Open

Comments

@tleyden
Copy link

tleyden commented Nov 4, 2017

When I build against version of ad5aa34 and run on IBM Cloud, this code is getting an error:

Unable to create request URL, because OpenWhisk API host is missing"

even though __OW_API_HOST and __OW_API_KEY are set to correct values in the environment (which is expected since it's running on IBM Cloud)

This same code was working fine against an older commit (b3d194d), so I think something changed in this library.

What updates do I need to make in my code to make this work?

Currently my code is directly loading the environment variables and passing that to the whisk.NewClient() call. Is that still the right way to do things? I believe I did that as a workaround to #23

@tleyden
Copy link
Author

tleyden commented Nov 4, 2017

As an experiment, I tried changing:

client, err := whisk.NewClient(http.DefaultClient, whiskConfig)

(where the whiskConfig struct is built up via this code)

to what's in the README:

client, err := whisk.NewClient(http.DefaultClient, nil)

and I'm getting this error:

OpenWhisk API host is missing (Please configure whisk.api.host.proto, whisk.api.host.name and whisk.api.host.port in whisk.properties under the OPENWHISK_HOME directory.)

How do those configuration instructions translate to running on IBM Cloud? I don't believe there is any direct access to whisk.properties AFAIK in that environment.

@csantanapr
Copy link
Member

Hum that's weird we refer to whisk.properties directly from the go code

@csantanapr
Copy link
Member

You point out IBM cloud not working, does that mean that it works when you deploy your own OpenWhisk from open source ?

@tleyden
Copy link
Author

tleyden commented Nov 4, 2017

I haven't tried that

@csantanapr
Copy link
Member

When is nil what are the values use for authkey and apihost?
I think should always expect a whiskConfig object and never nil

@csantanapr
Copy link
Member

I see a getDefaultConfig when nil is that suppose to load the settings from __OW... ?
https://github.com/apache/incubator-openwhisk-client-go/blob/master/whisk/client.go

@tleyden
Copy link
Author

tleyden commented Nov 4, 2017

Digging into this a bit more, I think I found a problem with the way my code is constructing the whiskConfig struct: it's setting the BaseURL field, but not the Host field, and it looks like the code expects the Host field to be set.

@csantanapr
Copy link
Member

Maybe that could fue recent change and README was not updated to reflect changes

@tleyden
Copy link
Author

tleyden commented Nov 4, 2017

Yeah I think the README should be updated to mention that the whisk.Config.Host field is required.

I just verified that setting the whisk.Config.Host field fixes it on IBM Cloud

I think from a user perspective the when using this library on IBM Cloud, the ideal usage would be:

config := whisk.NewConfig()
config.InitFromEnvironment()
client, err := whisk.Newclient(http.DefaultClient, config)

and InitFromEnvironment() would effectively be doing the same thing as WhiskConfigFromOwEnvVars()

@csantanapr
Copy link
Member

@tleyden yeah I think that would be good addition.
But this environment variables are not specific to IBM, they will work on any OpenWhisk deployment

@houshengbo
Copy link

@tleyden Reading the information of credentials from whisk.properties is deprecated now, but still supported.

We currently supports to read the credentials from $HOME/.wskprops.
You can configure the following information:

  • APIHOST, AUTH and NAMESPACE, which are mandatory.
  • APIGW_ACCESS_TOKEN, APIVERSION, KEY and CERT, which are optional.

Users do not need to care BaseURL any more. Instead, APIHOST is an easier configuration.

Reading credentials from environmental variables are not 100% guaranteed. The best way to to configure the $HOME/.wskprops.

@drcariel
Copy link
Contributor

drcariel commented Nov 6, 2017

To add: I ran into this problem a few weeks ago, but only when building from the cli specific repos. However, the cli/go client code within incubator-openwhisk did not have this problem. Maybe you should investigate there @tleyden , the code may be out of sync.

@tleyden
Copy link
Author

tleyden commented Nov 6, 2017

@houshengbo Thanks for the list of mandatory and optional fields. I think the library would be a bit easier to use if that was documented in the exported Config struct.

Reading credentials from environmental variables are not 100% guaranteed. The best way to to configure the $HOME/.wskprops.

I'm invoking this code from within an OpenWhisk action, which is running on IBM Cloud (though according to @csantanapr, the same would be true on any OpenWhisk installation). So reading from $HOME/.wskprops isn't an option.

@tleyden
Copy link
Author

tleyden commented Nov 6, 2017

@drcariel the CLI is running in a different context, and it can just expect to be able to check local files like $HOME/.wskprops. But in the context of a running action, the only thing available is environment variables.

Btw, I'm using an action to monitor walk the list of recent activations to look for failures, and then send alerts if there are any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants