vmware-archive / functions

Functions Repository for Kubeless
Apache License 2.0
70 stars 37 forks source link

Weather example #18

Closed andresmgot closed 6 years ago

andresmgot commented 6 years ago

cc @white-cloud

YasminBZ commented 6 years ago

@andresmgot the code works fine ; thank you for your help.

Another question please. i want to know the endpoint of the my function how i can do that ?

andresmgot commented 6 years ago

By default Kubeless does not expose the functions to be accessible from outside the cluster. If you want to create a public endpoint you can follow this guide: http://kubeless.io/docs/routing/

YasminBZ commented 6 years ago

For me it is okay to access the function inside the cluster , because i neeed to do some benchmark and for that we need the endpoint of the function

2018-03-03 12:16 GMT+01:00 Andres notifications@github.com:

By default Kubeless does not expose the functions to be accessible from outside the cluster. If you want to create a public endpoint you can follow this guide: http://kubeless.io/docs/routing/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kubeless/functions/pull/18#issuecomment-370139734, or mute the thread https://github.com/notifications/unsubscribe-auth/Ai-sm7TW4W2sxKDOrM04kVKi-S412eC7ks5tant-gaJpZM4SZtm7 .

andresmgot commented 6 years ago

the easiest way to access the function inside the cluster is using the kubectl proxy:

$ kubectl proxy &
$ curl -H "Content-Type: application/json" --data '{"a": "b"}' 127.0.0.1:8080/api/v1/proxy/namespaces/default/services/YOUR_FUNC_ID:http-function-port/
YasminBZ commented 6 years ago

Hello @andresmgot ,

Please i'm having an error when trying to call my function , and i'm using the new version of kubeless FATA[0000] an error on the server ("Internal Server Error") has prevented the request from succeeding

i really don't get what does it mean , i haven't seen this error before in my last executions ??

andresmgot commented 6 years ago

Hi @white-cloud,

That is caused by an internal error in the function. The logs should return some more information to debug the issue:

kubectl logs -l function=<your_function_name>
YasminBZ commented 6 years ago

Thank you @andresmgot

i'm trying actually to execute the same function weather in the kubeless v0.4.0 and v0.5.0 and i get the same error it worked fine before in the v0.4.0 but now when i'm trying to call the function it give the error

ERRO[0000] {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"no endpoints available for service \"weather:http-function-port\"","reason":"ServiceUnavailable","code":503}

FATA[0000] an error on the server ("unknown") has prevented the request from succeeding

andresmgot commented 6 years ago

Is the function pod still running? What is the output of executing:

kubectl get pod -l function=<your_function_name> -o yaml
kubectl describe pod -l function=<your_function_name>
kubectl logs -l function=<your_function_name>
kubectl get svc <your_function_name> -o yaml
kubectl get endpoints <your_function_name> -o yaml

In any case note that the function code has changed between the version 0.4.0 and 0.5.0 so if you haven't update your function code you need to do so.

YasminBZ commented 6 years ago

Hello @andresmgot , in kubeless 0.5.0 the pod is running when executing the log command here what i get as an output:

kubectl logs -l function=weather ::ffff:10.244.1.1 - - [12/Apr/2018:12:59:37 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.10" ::ffff:10.244.1.1 - - [12/Apr/2018:13:00:07 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.10" ::ffff:10.244.1.1 - - [12/Apr/2018:13:00:37 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.10" Function failed to execute: TypeError: Cannot read property 'location' of undefined at weather (/kubeless/handler.js:7:35) at modExecute (/kubeless.js:89:25) at /kubeless.js:50:29 at /kubeless/handler.js:20:20 at ContextifyScript.Script.runInContext (vm.js:59:29) at ContextifyScript.Script.runInNewContext (vm.js:65:15) at app.all (/kubeless.js:146:20) at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5) at next (/node_modules/express/lib/router/route.js:137:13) at next (/node_modules/express/lib/router/route.js:131:14) ::ffff:10.244.0.0 - - [12/Apr/2018:13:00:39 +0000] "POST / HTTP/1.1" 500 21 "-" "kubeless/v1.8.0+$Format:%h$ (linux/amd64) kubernetes/$Format" ::ffff:10.244.1.1 - - [12/Apr/2018:13:01:07 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.10"

What does this mean please??

andresmgot commented 6 years ago

From the logs:

Function failed to execute: TypeError: Cannot read property 'location' of undefined
at weather (/kubeless/handler.js:7:35)

You can see that the function is failing to retrieve the property locationfrom the data provided. How are you calling the function? Note that should be something like kubeless function call <your_function> --data '{"location": "nome, ak"}'. Also note that if you have upgraded your cluster you should upgrade the kubeless CLI tool as well.

YasminBZ commented 6 years ago

That's exactly the command i'm using to call the function , the weaird thing is that was working good in v0.4.0 last couple week and today when i used it again in the v0.4.0 i had always the pod crashblackoff (not in a running stat) so i coudl'nt call the function , then when using the same function in the v0.5.0 the pod is running , the kubeless ClUI in v 0.5.0 as well .

andresmgot commented 6 years ago

If that's the case note that the function code has changed. Can you confirm that you have updated the function after upgrading kubeless?

YasminBZ commented 6 years ago

I didn't update the function code ? i used only the code you post before in the project of weather nodejs example , it was working fine in the v0.4.0 but not anymore in the same version of kubeless v0.4.0, may i know where the problem is @andresmgot ??

YasminBZ commented 6 years ago

Please @andresmgot i really need some help about that ??

andresmgot commented 6 years ago

Yes, the issue is that the function signature changed in Kubeless 0.5.0 so all the functions working in previous versions should be updated. If you take a look to the current status of master of this repository (https://github.com/kubeless/functions/blob/master/incubator/weather/handler.js) you will see that the function is different, now Kubeless functions receive two params (event, context) instead of the previous (req, res). If you want to have more info these new parameters they are explained with detail here: http://kubeless.io/docs/runtimes/.

So to fix your issue please clone the latest status of this repository and execute kubeless function update --from-file ./incubator/weather/handler.js or delete your previous function and recreate it again.

Hope that helps.

YasminBZ commented 6 years ago

Thank you for your answer @andresmgot

what i don't undertand why it is not working in the last version v04.0 as it was before that's what i don't undertand ?? because it worked very well before !!!

andresmgot commented 6 years ago

I would need to see the logs from the previous version, if it is something temporary maybe the service this function relies on (https://query.yahooapis.com/v1/public) was down or there were some temporary issue in your kubernetes cluster.

YasminBZ commented 6 years ago

Good morning @andresmgot ,

i followed the step you montiioned in the last comment , i used the new function code to execute in the v0.5.0 still having the same issue .

FATA[0000] an error on the server ("Internal Server Error") has prevented the request from succeeding

with using the log command , getting the same answer about

at next (/node_modules/express/lib/router/route.js:131:14) ::ffff:10.244.0.0 - - [13/Apr/2018:07:25:31 +0000] "POST / HTTP/1.1" 500 21 "-" "kubeless/v1.8.0+$Format:%h$ (linux/amd64) kubernetes/$Format" Function failed to execute: TypeError: Cannot read property 'location' of undefined at weather (/kubeless/handler.js:7:37) at modExecute (/kubeless.js:89:25) at /kubeless.js:50:29 at /kubeless/handler.js:20:20 at ContextifyScript.Script.runInContext (vm.js:59:29) at ContextifyScript.Script.runInNewContext (vm.js:65:15) at app.all (/kubeless.js:146:20) at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5) at next (/node_modules/express/lib/router/route.js:137:13) at next (/node_modules/express/lib/router/route.js:131:14)

I used actually the weather function in fission and i get a normal answer , didn't have an issue , so probably the problem not in the (https://query.yahooapis.com/v1/public) .

YasminBZ commented 6 years ago

@andresmgot Thank you so much for your help , it's working now :)

Thank you again for your help :)