serverless / serverless-kubeless

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

Unable to deploy serverless-kubeless functions from Windows #93

Closed vishweshwarp closed 6 years ago

vishweshwarp commented 6 years ago

Commands executed:

git clone https://github.com/serverless/serverless-kubeless cd examples\get-python npm install serverless deploy

Error log:

Serverless: Packaging service... Serverless: Excluding development dependencies...

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

ENOENT: no such file or directory, open 'C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\C'

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

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

Error: ENOENT: no such file or directory, open 'C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\C' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at _.each.configFile (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\lib\helpers.js:31:43) at arrayEach (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\lodash\lodash.js:537:11) at Function.forEach (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\lodash\lodash.js:9359:14) at Object.loadKubeConfig (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\lib\helpers.js:30:7) at new Functions (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\nodemodules\serverless-kubeless\lib\functions.js:29:60) at .each (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\lib\deploy.js:294:30) at arrayEach (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\lodash\lodash.js:537:11) at Function.forEach (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\lodash\lodash.js:9359:14) at BbPromise (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\lib\deploy.js:292:7) at deploy (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\lib\deploy.js:291:10) at BbPromise.then (C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\node_modules\serverless-kubeless\deploy\kubelessDeploy.js:129:19) From previous event: at PluginManager.invoke (C:\Users\myusername\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:368:22) at PluginManager.run (C:\Users\myusername\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:399:17) at variables.populateService.then (C:\Users\myusername\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:102:33) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5) From previous event: at Serverless.run (C:\Users\myusername\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:89:74) at serverless.init.then (C:\Users\myusername\AppData\Roaming\npm\node_modules\serverless\bin\serverless:42:50) at

Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Forums: forum.serverless.com Chat: gitter.im/serverless/serverless

Your Environment Information ----------------------------- OS: win32 Node Version: 8.9.3 Serverless Version: 1.25.0

Error says

Error: ENOENT: no such file or directory, open 'C:\Users\myusername\workspace\serverless-kubeless\examples\get-python\C'

But there is no directory with name "\C" under cloned example "serverless-kubeless\examples\get-python" directory.

I am using Kubeless version v0.3.1 on Kubernetes. Everything works fine if I directly create functions on Kubeless.

vishweshwarp commented 6 years ago

Found the root cause.

As per Kubernetes documentation, https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable

The KUBECONFIG environment variable is a list of paths to configuration files. The list is colon-delimited for Linux and Mac, and semicolon-delimited for Windows.

At line 29 in "serverless-kubeless/lib/helpers.js" file, we are splitting KUBECONFIG paths list with hard coded colon. Due to this Windows paths are split incorrectly at drive colon character (C:).

const configFiles = process.env.KUBECONFIG.split(':');

When I added made delimiter conditional based on OS in my local helpers.js file, functions got deployed to Kubeless successfully.

Will submit this fix for review.

chipironcin commented 6 years ago

Wow, great find @vishweshwarp Thanks for posting the solution and contributing it back to the repository.

Our team will take a look at your PR soon. Thanks again :+1:

ngtuna commented 6 years ago

Thanks @vishweshwarp for the fix 👍 . The PR is good to be landed.