英文:
Error: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
问题
我需要一个关于这个问题的“白痴”级别的答案,我知道这个问题以前被问过。
我们正在使用Serverless框架来托管在AWS上的应用程序。 Runtime=python3.8
我们有一个包含16个函数的大型yml文件,其中有2个函数包括用于加密和PyNaCl的层,我们从这里获取 - https://github.com/keithrozario/Klayers,并且已经成功使用了相当长时间。
上周,我需要更新一个不同的函数,这意味着重新测试,这意味着找到了Cryptography层的更新版本,所以我将其更新为Cryptography v.39。现在我有一个出现错误的函数,错误消息为:/lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
这个函数自07/2022以来就没有被使用过,当时它还很正常。显然,从Serverless重新部署以来已经有这么长时间了。
尝试解决问题:
- 我回滚到以前的Cryptography层;没有任何区别
- 我找到一个SO答案,其中包含此链接 https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/,按照该指南更改了我的本地安装,并在控制台中附加了自己的层;没有任何区别
- 另一个SO答案将我引导到这里 - https://github.com/pyca/cryptography/issues/6390,然后跳转到 https://github.com/pyca/cryptography/issues/6391,这也没有帮助
- 今天,我发现了这个链接 https://repost.aws/questions/QU85KE-2hPQ4KDQyByKV_WIw/creating-a-lambda-zip-package-that-runs-python-package-cryptography,OP说他们不得不将所有的lambda从x86_64切换到arm64,即使那些函数不使用Cryptography。这似乎是疯狂的,而且...怎么做?
这个问题 https://stackoverflow.com/questions/69475140/lambda-function-failing-with-lib64-libc-so-6-version-glibc-2-18-not-found 包括建议从Cryptography v.39 回退到v.3.4.7(从03/2021),这似乎是不好的建议。毫无疑问,这两个版本之间的14次更新包括一些重要的更改。
我感到非常困惑。我感觉自己一直在打转,与此同时无法在我尝试更新的实际函数上取得进展,因为这是一个巨大的障碍。
英文:
I need a 'for dummies' answer to this question that I know has been asked before.
We're using the Serverless framework for an AWS-hosted application. Runtime=python3.8
Got a nice big yml file that includes 16 functions, 2 of which include layers for Cryptography and for PyNaCl, which we bring in from here - https://github.com/keithrozario/Klayers and have used successfully for quite a while.
Last week, I needed to update a different function, which meant re-testing, which meant finding there's a newer version of the cryptography layer, so I updated it to have Cyptography v.39. Now I have a function that fails with the error, /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
This function hasn't been used since 07/2022, at which time it was just fine. Apparently it's also been that long since we redeployed from Serverless.
Attempts to fix:
- I reverted to the previous Cryptography layer; no difference
- I found an SO answer with this link https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/, followed that guide to change my local install and also to make my own layer and attach it in the console; no difference
- Another SO answer led me here - https://github.com/pyca/cryptography/issues/6390, which then goes to https://github.com/pyca/cryptography/issues/6391, which also didn't help
- Today, I found this link https://repost.aws/questions/QU85KE-2hPQ4KDQyByKV_WIw/creating-a-lambda-zip-package-that-runs-python-package-cryptography and the OP says they had to make all of their lambdas from x86_64 to arm64, even if those functions weren't using Cryptography. That's seems insane, and besides.... how??
This question https://stackoverflow.com/questions/69475140/lambda-function-failing-with-lib64-libc-so-6-version-glibc-2-18-not-found includes the advice to move from Cryptography v.39 all the way back to v.3.4.7 (from 03/2021), which seems like bad advice. Surely the 14 updates between those 2 versions include some important changes.
I'm at a loss. I feel like I'm just running in circles, and meanwhile can't make progress on the actual function I'm trying to update because this is such a block.
答案1
得分: 5
我正在使用Serverless和https://www.npmjs.com/package/serverless-python-requirements来打包一个Python 3.9函数,遇到了相同的错误。我向serverless插件添加了一些pip参数,以指定目标系统,这让我成功解决了这个问题:
pipCmdExtraArgs: ['--platform manylinux2014_x86_64', '--only-binary=:all:']
这是我在插件中使用的完整配置(来自我的serverless.ts文件):
pythonRequirements: {
dockerizePip: false,
usePoetry: false,
layer: true,
useDownloadCache: false,
useStaticCache: false,
pipCmdExtraArgs: ['--platform manylinux2014_x86_64', '--only-binary=:all:'],
slim: true
}
这会生成类似这样的pip安装命令(以防你在流水线中手动调用pip安装):
python3.9 -m pip install --platform manylinux2014_x86_64 --only-binary=:all: -t /someOutputFolder -r requirements.txt
更新:我发现另一个选项是在Lambda容器中使用Docker容器,并在Dockerfile中安装Python依赖项,可以参考这些文档:https://docs.aws.amazon.com/lambda/latest/dg/images-create.html
Serverless使部署容器映像变得非常简单:https://www.serverless.com/blog/container-support-for-lambda
英文:
I'm using Serverless and https://www.npmjs.com/package/serverless-python-requirements to bundle a Python 3.9 function, and was hitting the same error. I added a couple of pip args to the serverless plugin to specify the target system, which got me past the issue:
pipCmdExtraArgs: ['--platform manylinux2014_x86_64', '--only-binary=:all:']
Here is the full config I'm using for the plugin (from my serverless.ts):
pythonRequirements: {
dockerizePip: false,
usePoetry: false,
layer: true,
useDownloadCache: false,
useStaticCache: false,
pipCmdExtraArgs: ['--platform manylinux2014_x86_64', '--only-binary=:all:'],
slim: true
}
which results in a pip install command that looks like this (just in case you are calling pip install manually in your pipeline):
python3.9 -m pip install --platform manylinux2014_x86_64 --only-binary=:all: -t /someOutputFolder -r requirements.txt
Update: Another option I've found is to use a docker container as the lambda container, and install the python dependencies in the dockerfile, as shown in these docs: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html
Serverless makes it really easy to deploy the container image: https://www.serverless.com/blog/container-support-for-lambda
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论