serverless / serverless-kubeless

This plugin enables support for Kubeless within the Serverless Framework.
Apache License 2.0
303 stars 80 forks source link

Error "Not Found" during "invoke" verb? error invoking at least Ruby or Python #132

Closed kingdonb closed 6 years ago

kingdonb commented 6 years ago

I'm trying to get this working and I seem to have hit a bug in the serverless client, or kubeless plugin to it.

$ serverless invoke -f hello -l
Serverless: Calling function: hello...

  Error --------------------------------------------------

  Not Found

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.4.1
     Serverless Version:     1.27.3

$ kubeless function call hello
v1.0.0-alpha.6

So it looks like my "hello" function is installed correctly. I can call it directly with the 'kubeless' function call verb. I started with the example from serverless-ruby repo which is meant for AWS and simplified it to use the serverless-ruby plugin instead, but I wound up swapping almost everything out for the version.rb contents in the ruby-get example here, in this project.

These are my repo contents:

serverless.yml

service: index

provider:
  name: kubeless
  runtime: ruby2.4

plugins:
  - serverless-kubeless

functions:
  hello:
    handler: index.hello

package.json

{
  "name": "hello",
  "version": "1.0.0",
  "description": "Example function for serverless kubeless",
  "dependencies": {
    "serverless-kubeless": "^0.4.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": ""
}

index.rb

def hello(event, context)
  require "net/https"
  require "uri"
  require "json"

  # Fetch release info
  uri = URI.parse("https://api.github.com/repos/bitnami/kubeless/releases")
  http = Net::HTTP.new(uri.host, uri.port)
  request = Net::HTTP::Get.new(uri.request_uri)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  response = http.request(request)

  # Follow redirects if needed
  if response.code == "301"
    response = Net::HTTP.get_response(URI.parse(response.header['location']))
  end

  # Parse response
  output = JSON.parse(response.body)
  puts output
  # Create a Hash for output
  output_hash = { :version => output[0]['tag_name'] }

  return output_hash[:version]
end

The examples are the same if I try with the serverless-kubeless examples/get-ruby itself.

I can invoke the functions through the kubeless client but not the serverless invoker. At first I thought it was actually the fact that I was missing kubeless client itself, but now I have it and I still have the issue with serverless invoke as below:

~/projects/serverless-kubeless/examples/get-ruby (master u=)$ serverless invoke -f version
Serverless: Calling function: version...

  Error --------------------------------------------------

  Not Found

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.4.1
     Serverless Version:     1.27.3

~/projects/serverless-kubeless/examples/get-ruby (master u=)$ kubeless function call version
v1.0.0-alpha.6

I think "Not Found" must be coming from somewhere, in case the stack trace is helpful here it is from SLS_DEBUG=*

kbarret8@kbarret8-mbp:~/projects/serverless-kubeless/examples/get-ruby (master u=)$ export SLS_DEBUG='*'
kbarret8@kbarret8-mbp:~/projects/serverless-kubeless/examples/get-ruby (master u=)$ serverless invoke -f version
Serverless: Load command run
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command emit
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command info
Serverless: Load command logs
Serverless: Invoke invoke
Serverless: Calling function: version...

  Error --------------------------------------------------

  Not Found

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: Not Found
    at Request.parseReponse [as _callback] (/Users/kbarret8/Desktop/devel/serverless-kubeless/examples/get-ruby/node_modules/serverless-kubeless/lib/invoke.js:110:18)
    at Request.self.callback (/Users/kbarret8/Desktop/devel/serverless-kubeless/examples/get-ruby/node_modules/request/request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.EventEmitter.emit (domain.js:442:20)
    at Request.<anonymous> (/Users/kbarret8/Desktop/devel/serverless-kubeless/examples/get-ruby/node_modules/request/request.js:1157:10)
    at Request.emit (events.js:182:13)
    at Request.EventEmitter.emit (domain.js:442:20)
    at IncomingMessage.<anonymous> (/Users/kbarret8/Desktop/devel/serverless-kubeless/examples/get-ruby/node_modules/request/request.js:1079:12)
    at Object.onceWrapper (events.js:273:13)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
From previous event:
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:372:22)
    at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:403:17)
    at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:102:33)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
    at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:89:74)
    at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:42:50)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.4.1
     Serverless Version:     1.27.3

I get the exact same result from the Python example, I can call the function through kubeless function but the serverless client does know know where to find it.

Here's my package-lock.json in a gist too, in case that is helpful:

$ cat package-lock.json

...

https://gist.github.com/kingdonb/d87bfefbee7de89a431082b429211b1b

andresmgot commented 6 years ago

Hi @kingdonb, I think I found the issue, are you running Kubeless in Kubernetes 1.10?

kingdonb commented 6 years ago

That's right, latest minikube has v1.10 kubelet

andresmgot commented 6 years ago

we have released v0.4.4, that should fix your issue

kingdonb commented 6 years ago

Great! Thanks, I will test and close when I see it too.

kingdonb commented 6 years ago

It works!