-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lambda: jsonschema import fails with lambda using aws-cdk 2.87.0 #26300
Comments
Thank you for your report. I just can't find any root cause off the top of my head. As I can't see your lambda code, are you able to create a mini repo that I can clone and reproduce this error in my account? |
I found that if you use 2.87.0 of aws-cdk it still works ok |
Same here! |
Also see this issue: python-jsonschema/jsonschema#1117. |
Pcluster API execution fails if using the latest version of the packages. * jsonschema introduced breaking changes in 4.18.0 in July 2023, see aws/aws-cdk#26300. Therefore, we use version 4.17.3. * urllib released 2.0 in May 2023. Pcluster API has been released with urllib 1.x. Therefore, we use version 1.x. It is not clear why the problems started with ParallelCluster 3.8.0 release process. * For jsonschema, ParallelCluster 3.7.2 used 4.19.1 and did not have any problem. * For urllib, previous versions of ParallelCluster API used 1.x. It is not clear why the code didn't fetch the new version earlier. I suspect there were some changes in our Python environment on our internal testing infrastructure or on AWS Lambda. Signed-off-by: Hanwen <[email protected]>
Pcluster API execution fails if using the latest version of the packages. * jsonschema introduced breaking changes in 4.18.0 in July 2023. Therefore, we use version 4.17.3. aws/aws-cdk#26300 * urllib released 2.0 in May 2023. Pcluster API has been released with urllib 1.x. Therefore, we use version 1.x. The root cause of both issues are because Lambda Function environment has older boto3/botocore versions than latest released versions on PyPi. Specifically, when we prepare lambda layers, the dependencies are installed according to new boto3/botocore versions. When running the Lambda function, the older boto3/botocore are not compatible with the dependencies we provide in Lambda layers. Signed-off-by: Hanwen <[email protected]>
Pcluster API execution fails if using the latest version of the packages. * jsonschema introduced breaking changes in 4.18.0 in July 2023. Therefore, we use version 4.17.3. aws/aws-cdk#26300 * urllib released 2.0 in May 2023. Pcluster API has been released with urllib 1.x. Therefore, we use version 1.x. The root cause of both issues are because Lambda Function environment has older boto3/botocore versions than latest released versions on PyPi. Specifically, when we prepare lambda layers, the dependencies are installed according to new boto3/botocore versions. When running the Lambda function, the older boto3/botocore are not compatible with the dependencies we provide in Lambda layers. Signed-off-by: Hanwen <[email protected]>
This was not necessary because we used Lambda runtime Python 3.9, which contains boto3-1.26.90, which does not rely on jsonschema. After using Lambda runtime Python 3.12, we are using a newer boto3 version and reply on jsonschema. We need to pin the jsonschema because of a known issue: aws/aws-cdk#26300 Signed-off-by: Hanwen <[email protected]>
This was not necessary because we used Lambda runtime Python 3.9, which contains boto3-1.26.90, which does not rely on jsonschema. After using Lambda runtime Python 3.12, we are using a newer boto3 version and reply on jsonschema. We need to pin the jsonschema because of a known issue: aws/aws-cdk#26300 Signed-off-by: Hanwen <[email protected]>
This was not necessary because we used Lambda runtime Python 3.9, which contains boto3-1.26.90, which does not rely on jsonschema. After using Lambda runtime Python 3.12, we are using a newer boto3 version and reply on jsonschema. We need to pin the jsonschema because of a known issue: aws/aws-cdk#26300 Signed-off-by: Hanwen <[email protected]>
This was not necessary because we used Lambda runtime Python 3.9, which contains boto3-1.26.90, which does not rely on jsonschema. After using Lambda runtime Python 3.12, we are using a newer boto3 version and reply on jsonschema. We need to pin the jsonschema because of a known issue: aws/aws-cdk#26300 Signed-off-by: Hanwen <[email protected]>
I'm unable to replicate the bug, so I'm assuming the previous commits and lack of comments means the issue has been fixed, and it can be safely closed. For reference, this was the code I used, in CDK 2.140.0: import os
from aws_cdk import Duration, Stack
from aws_cdk.aws_lambda import Runtime, Architecture
from aws_cdk.aws_lambda_python_alpha import PythonLayerVersion, PythonFunction
from aws_cdk.aws_logs import RetentionDays
from constructs import Construct
class IssueJsonschemaStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
lambda_layer = PythonLayerVersion(
self,
id=f"lambda-layer",
layer_version_name=f"lambda-layer",
compatible_runtimes=[Runtime.PYTHON_3_8],
entry=os.path.join("lambda"),
)
_lambda = PythonFunction(
self,
id=f"lambda",
function_name=f"lambda",
entry="lambda",
index="index.py",
handler="lambda_handler",
architecture=Architecture.ARM_64,
runtime=Runtime.PYTHON_3_8,
memory_size=1024,
layers=[
lambda_layer,
],
log_retention=RetentionDays.SIX_MONTHS,
timeout=Duration.minutes(1),
environment={
"some_env_var": "value",
},
) If the problem persists, please feel free to open another issue. |
|
We were getting an error ` No module named 'rpds.rpds` This issue comment aws/aws-cdk#26300 (comment) says we need to pin the jsonschema import to that version. This has stopped the error. Also, head_object in boto3 needs named arguments and I've updated the tests to reflect this.
Describe the bug
Our lambda uses jsonschema, installed through an requirements.txt file at deployment time into a lambda layer which gets attached to our lambda.
We realized the following behaviour after the update to 2.87.0 of aws-cdk stated in our CloudWatch logs of the lambda:
We narrowed down the issue to the import of jsonschema. It seems to be working if we switch back to aws-cdk 2.86.0.
Expected Behavior
import jsonschema in lambda will not give error.
Current Behavior
Error of
without trace given as soon as jsonschema is getting imported in our lambda.
Reproduction Steps
lambda_requirements.txt:
cdk code for lambda with layer from lambda_requirements.txt:
Possible Solution
Switching back to aws-cdk 2.86.0 resolves this issue.
Additional Information/Context
From pipeline using aws-cdk 2.87.0 (failing):
From pipeline using aws-cdk 2.86.0 (working):
CDK CLI Version
2.87.0
Framework Version
No response
Node.js Version
16
OS
linux
Language
Python
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: