Closed iainduncani closed 8 years ago
@iainduncani I tried out the wsk action list /whisk.system/samples
on my namespace with fresh installed CLI in Bluemix and it generally seems to work. Could you pls do two things:
wsk -v ...
and post the details here. Another options is to download and refresh the CLI.sudo pip install --upgrade https://new-console.ng.bluemix.net/openwhisk/cli/download
Hi,
Thanks for getting back to me so quickly, so when you listed the samples did it contain the countdown and wcbin samples? I just get four samples and they don't include those. Running with the -v flag I get this:
wsk -v action invoke countdown --blocking --result --param n 10
{'apihost': 'openwhisk.ng.bluemix.net', 'namespace': 'iain.duncan@uk.ibm.com_iainduncani', 'clibuild': '2016-03-14T11:48:47-05:00', 'apiversion': 'v1'}
========
REQUEST:
POST https://openwhisk.ng.bluemix.net/api/v1/namespaces/iain.duncan%40uk.ibm.com_iainduncani/actions/countdown?blocking=true
Headers sent:
{
"Authorization": "Basic ....",
"Content-Type": "application/json"
}
Body sent:
{"n": 10}
--------
RESPONSE:
Got response with code 200
Body received:
{
"name": "countdown",
"subject": "iain.duncan@uk.ibm.com",
"activationId": "28f609bce5b042ebabe63cecf1e9ef17",
"publish": false,
"annotations": [],
"version": "0.0.2",
"response": {
"result": {
},
"success": true,
"status": "success"
},
"end": 1458119292327,
"logs": ["2016-03-16T09:08:12.315440019Z stdout: 10",
"2016-03-16T09:08:12.40526866Z stdout: error: The requested resource does not exist. activation: undefined"],
"start": 1458119292308,
"namespace": "iain.duncan@uk.ibm.com"
}
========
{}
Do you know how to turn the logging on in whisk.js, I see it has a logger but I couldn't work out how to turn it on, I think that would be more useful as it is the call to whisk.invoke that is failing and it looks like the -v flag only enables logging for the initial call from the cli.
Thanks,
Iain
We don't install all these samples by default. You can create and install it yourself.
The reason countdown isn't installed for example is that it is recursive and does not for simplicity specify the namespace for the action. So if it was installed as a sample but invoked by a different subject, that subject must have countdown in their namespace (assets) otherwise the invoke will fail with "not found".
If running on Bluemix, make sure the action you are invoking is using a fully qualified name including the namespace you are in when using Bluemix (e.g., /duncan_dev/myAction
). From the CLI you can see your namespaces with wsk namespace list
and you can change it with wsk property set --namespace
I tried it out and observed two things:
jerewern@de.ibm.com
IBM Whisk_dev
I've created the countdown
action in my private namespace jerewern@de.ibm.com
wsk property set --namespace jerewern@de.ibm.com
wsk action create countdown ~/repos/openwhisk/catalog/samples/countdown.js
Then I invoked with the action with payload 10 and polled for activations:
wsk -v action invoke countdown --result --param n 10 && wsk activation poll
The result was:
{'apihost': 'openwhisk.ng.bluemix.net', 'namespace': 'jerewern@de.ibm.com', 'clibuild': '2016-03-14T11:48:47-05:00', 'apiversion': 'v1'}
========
REQUEST:
POST https://openwhisk.ng.bluemix.net/api/v1/namespaces/jerewern%40de.ibm.com/actions/countdown?blocking=false
Headers sent:
{
"Authorization": "Basic ...",
"Content-Type": "application/json"
}
Body sent:
{"n": 10}
--------
RESPONSE:
Got response with code 202
Body received:
{
"activationId": "c58ff5e7be48484d8307aa05e1ba7385"
}
========
ok: invoked countdown with id c58ff5e7be48484d8307aa05e1ba7385
Hit Ctrl-C to exit.
Polling for logs
Activation: countdown (c58ff5e7be48484d8307aa05e1ba7385)
2016-03-16T12:24:56.660929186Z stdout: 10
Activation: countdown (a24222493cab462990abd8fb08a2949e)
2016-03-16T12:24:58.894317389Z stdout: 1
Activation: countdown (12f925efe82a422bb429486a4f63cd5d)
2016-03-16T12:24:58.764294933Z stdout: 2
Activation: countdown (8a32481387f04e19acbcf0db43d49183)
2016-03-16T12:24:58.609439368Z stdout: 3
Activation: countdown (7785546d81ae436983051d8a4a17d49f)
2016-03-16T12:24:58.48465004Z stdout: 4
Activation: countdown (c923a733d95a4315be43b64106ee5b71)
2016-03-16T12:24:58.341544907Z stdout: 5
Activation: countdown (817639d1eb0b420696e1cffb3d521210)
2016-03-16T12:24:58.21428389Z stdout: 6
Activation: countdown (45d2889a871244f2821b46d71e218eae)
2016-03-16T12:24:58.068858345Z stdout: 7
Activation: countdown (ff03984f585644248871afce7e307644)
2016-03-16T12:24:57.93999077Z stdout: 8
Activation: countdown (3aa7dcf6959f457290edb98ce6ff5f43)
2016-03-16T12:24:57.787400733Z stdout: 9
Activation: countdown (5e92a55423e54cd39a2ed42e309fb9d5)
2016-03-16T12:24:59.988973547Z stdout: 0
2016-03-16T12:24:59.98928067Z stdout: Happy New Year!
This is consistent with what I pointed out: the countdown example does not fully qualify the action name. Hence it will only work if you fully qualify the action in the code. Or as you did, create the action in the default namespace (which is assumed when you don't fully qualify an action name).
Since the first question was about running in Bluemix, you have to qualify the action name with the namespace you're running in or change your namespace as suggested by @jeremiaswerner.
Thanks, I've got this working by changing my namespace as described by @jeremiaswerner. I had also tried to qualify the action name by doing this:
name : '/iain.duncan@uk.ibm.com_iainduncani/countdown'
but that didn't have any affect, @rabbah is that what you mean by qualifying the action name?
Cheers, Iain
@iainduncani Here is how I changed the countdown.js
sample to invoke from any namespace.
function main(params) {
var n = parseInt(params.n);
console.log(n);
if (n == 0) {
console.log('Happy New Year!');
} else if (n > 0) {
whisk.invoke({
name : '/'+(params.namespace||'_')+'/countdown',
parameters : {
namespace: params.namespace,
n : n - 1
},
next : function(error, activation) {
if (!error) {
whisk.done();
} else {
whisk.error(error);
}
}
});
return whisk.async();
}
}
wsk action update /XXX/countdown countdown.js
wsk action invoke countdown -p namespace XXX -p n 10
will create the action in the namespace XXX
and invoke it from same namespace.
Is this resolved? Is there documentation missing?
I'm not sure if I'm the right person to answer that question @sjfink but I'd make a few comments as a novice user:
OK, so it seems the main TODOs are to improve the documentation around these cases.
Thanks, Ian.
Closing as duplicate of #387 - the action should know which namespace it is running in.
I've been trying to invoke a whisk action from my JavaScript running on Bluemix similar to what is documented here:
https://github.com/openwhisk/openwhisk/blob/master/docs/reference.md#additional-sdk-methods
However, I haven't been able to get this to work. I did see there are some samples that show how to do this for instance:
https://github.com/openwhisk/openwhisk/blob/88cb9961d5d3553026a94113908a3867a6d76170/catalog/samples/wcbin.js https://github.com/openwhisk/openwhisk/blob/88cb9961d5d3553026a94113908a3867a6d76170/catalog/samples/countdown.js
However, even if I just copy and paste these samples I get this error coming back in my next callback:
error: The requested resource does not exist. activation: undefined"
Does anyone have any thoughts as to why this is? I also noticed that on Bluemix if I run:
wsk action list /whisk.system/samples
That it doesn't list either of these samples in the list so I wondered if that was because this functionality isn't supported yet or is known to fail?
Thanks for your help!