juanjoDiaz / serverless-plugin-warmup

Keep your lambdas warm during winter. ♨
MIT License
1.11k stars 113 forks source link

Incompatibility between serverless-plugin-warmup and serverless-plugin-canary-deployments #182

Closed xanol closed 4 years ago

xanol commented 5 years ago

I'm doing a canary deployment to a function, but I'm running into an issue warming the correct function alias. If I set SERVERLESS_ALIAS at the provider environment level, the env variable does not get set on the warming lambda, so after deployment it warms the $LATEST version. Even though this is now the same code as the canary version, you still experience cold starts because the API Gateway integration is invoking the Live version. (or, whatever you name the alias.)

If I set SERVERLESS_ALIAS: Live in the warmup config, it sets the runtime environment of the Lambda correctly, but the warming step fails because there is no canary version of the warming function itself. (Only $LATEST) So, you get an error like this:

ServerlessError: Function not found: arn:aws:lambda:us-east-1:111111111111:function:service-name-warmup-plugin:Live: WarmUp: Error while pre-warming functions

because it's looking for the Live version.

juanjoDiaz commented 4 years ago

Hi @xanol ,

Sorry for the slow response.

Humm I think that the SERVERLESS_ALIAS thingy was initially created to be used with the serverless-aws-alias plugin since serverless doesn't support aliases natively.

This plugin ignore all the env vars set at the provider level. So you always need to configure the specific variables in the warmup object.

So this seems like a bug and I need to check it 🙂

juanjoDiaz commented 4 years ago

Are you using the serverless-aws-alias plugin? If so, are you declaring it after the warmup plugin? That might solve your issue.

xanol commented 4 years ago

No, we are using serverless-plugin-canary-deployments. I think it's an incompatibility with the two plugins. Our workaround was to set prewarm: false, since the lambda should get warmed during the canary period anyway.