serverless / serverless-openwhisk

Adds Apache OpenWhisk support to the Serverless Framework!
http://openwhisk.org/
MIT License
143 stars 47 forks source link

Using more than one serverless.yml #162

Closed ericqqqqq closed 5 years ago

ericqqqqq commented 5 years ago

I am currently using serverless.yml to deploy my actions to IBM Cloud. Now, I guess because of the large amount of actions I have to deploy every time, I am hitting 502 gateway too often.

The way I solve 502 issue so far is to deploy the first half of my actions first, and then deploy the rest of actions. I found this process is tedious and annoying. Now, I am thinking is there any way to manage these actions in several serverless.yml (eg, my first half goes to serverless1.yml, and my second half goes to serverless2.yml)

So that, I can automate my way to solve 502 gateway error. Alternatively, I am happy to hear any other better way to get rid of 502 gateway error.

Error:

serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling Functions...
Serverless: Compiling Packages...
Serverless: Compiling API Gateway definitions...
Serverless: Compiling Rules...
Serverless: Compiling Triggers & Feeds...
Serverless: Compiling Service Bindings...
Serverless: Deploying Packages...
Serverless: Deploying Functions...

  Serverless Error ---------------------------------------

  Failed to deploy function (myPackageName/myActionName) due to error: PUT https://us-south.functions.cloud.ibm.com/api/v1/namespaces/_/actions/myPackageName/myActionName?overwrite=true Returned HTTP 502 (Bad Gateway) --> "Response Missing Error Message."

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

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.15.0
     Serverless Version:     1.33.2

   ╭───────────────────────────────────────╮
   │                                       │
   │   Update available 1.33.2 → 1.39.1    │
   │   Run npm i -g serverless to update   │
   │                                       │
   ╰───────────────────────────────────────╯

make: *** [serverless-deploy] Error 1
jthomas commented 5 years ago

👋 @ericqqqqq

Sorry to hear you are having issues. Can you answering me the following questions...

If you are hitting intermittant platform issues - I can ask the platform team to investigate. If you are hitting some rate limiting errors - I can look at introducing a different approach to deploying huge amounts of actions to try and resolve it.

ericqqqqq commented 5 years ago

@jthomas Hi, I want to apologize for my late reply first.

Answer to questions:

provider: name: openwhisk runtime: nodejs:10

custom:

some-env-variables

resources: packages:

my package scope variable and package name is defined here

functions:

24 actions, (some of them are created with default parameters, example as followed)

myAction: name: "packageName/actionName" handler: myHandlerLocation parameters: myDefaultParameter: myValue plugins:

ericqqqqq commented 5 years ago

👋@jthomas
Do you have any updates on this issue?

jthomas commented 5 years ago

I'm been testing out a similiar size project to the above but can't replicate the error I'm afraid (in the London region). Here's the test files I'm using - can you try them out and see if you are still having that issue?

service: too-large

provider:
  name: openwhisk
  runtime: nodejs:10

functions:
  hello_0:
    handler: handler.hello
  ...
  hello_24:
    handler: handler.hello

plugins:
  - serverless-openwhisk
{
  "name": "too-large",
  "version": "1.0.0",
  "description": "Sample OpenWhisk NodeJS serverless framework service.",
  "main": "handler.js",
  "keywords": [
    "serverless",
    "openwhisk"
  ],
  "devDependencies": {
    "serverless-openwhisk": ">=0.13.0"
  },
  "dependencies": {
    "mocha": "^6.1.2",
    "sentiment": "^5.0.1"
  }
}
'use strict';
const Sentiment = require('sentiment');

function hello(params) {
  const sentiment = new Sentiment()
  const result = sentiment.analyze(params.message || 'Cats are stupid.');
  return { result };
}

exports.hello = hello;

solution?

I could guess since each function deployment in the configuration is sent as a parallel request this might be rejected by the platform due to rate limiting. One solution would be to modify the line here: https://github.com/serverless/serverless-openwhisk/blob/master/deploy/lib/deployFunctions.js#L42-L43

...to use Bluebird Promise libraries map function which has a concurrency option which could be set to 1 or a low number to ensure not too many requests are being sent at once.

Could you test this out in your project and let me know if that works? If so, we can turn it into a PR and merge back upstream.

ericqqqqq commented 5 years ago

Hi @jthomas Thanks for the help, to be honest, this error happens randomly and it is unpredictable here😔. It is not happening to me every single time. Weird thing is after I opened an issue here, I have not seen the same error again.

Since I am using openwhisk serverless almost every day. I will test with your solution if it happens again. I will 100% let you know how it works.

jthomas commented 5 years ago

@ericqqqqq If this is happening on IBM Cloud, feel free to open a support ticket to get them to look into it!

jthomas commented 5 years ago

Closing due to lack of activity on this issue...