python-lambda icon indicating copy to clipboard operation
python-lambda copied to clipboard

Lambda deploy : call to `update_configuration_function` is made before lambda update status is ready

Open roamdam opened this issue 3 years ago • 5 comments

Problem

It seems that the application of lambda states to all functions, including zip-file based lambdas, prevents from deploying as previously with lambda deploy. Several lambdas that I was able to deploy perfectly last week do not deploy now.

Error

The error I'm getting is the following

botocore.errorfactory.ResourceConflictException: An error occurred (ResourceConflictException) when calling the UpdateFunctionConfiguration operation: The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:eu-west-3:xxx:function:my-lambda

Observations

It seems that right after calling the client.update_function_code method, the LastUpdateStatus from the lambda's configuration stays at InProgress, thus the subsequent call to client.update_function_configuration is refused by the API.

I've tried adding a simple time.sleep(120) right after the call to client.update_function_code, and it seems to work : after waiting the value of LastUpdateStatus goes back to Successful, and the deployment goes fine afterwards.

roamdam avatar Nov 26 '21 00:11 roamdam

@nficano any chance to get the PR from rashadmoarref approved ? I have been using his fix as well it it is working fine !

Thanks.

Lowess avatar Feb 22 '22 10:02 Lowess

Sleep looks like hack and what if you are updating many functions in same time? deployment will be very long. Possible solutions:

  1. First deploy code and deploy new configuration -> than change status to published in separate command. Haven't tried yet but according docs should work
  2. Much less acceptable is to try fetch status from AWS and when it's published try change config. but after is still need to be published. (Bad solution)
  3. just sleep and hope that AWS updates (but you can not guarantee that in 90 seconds function will be published) so it can fail if AWS degraded anyway.

I think we need to go by way 1 so there will be no delays in deployments and guarantee that status changes after all changes are done. PR above can be used as temp fix and can work but not in 100% times and makes deployments much longer!

znotdead avatar Apr 19 '22 18:04 znotdead

Okay. As everything is async I've used client waiter to make configuration changes during update. PR https://github.com/nficano/python-lambda/pull/716

znotdead avatar Apr 19 '22 21:04 znotdead

I can see this issue has been resolved in #714 but the latest version available on pip is 11.8.0 from over a year ago. https://pypi.org/project/python-lambda/

Is it possible to publush a new version please so we can have access to the latest code via pip?

vorte avatar Sep 20 '22 08:09 vorte