Skip to content

Emr Serverless can't run a custom build

0

Hello,

For the experiment I took the image public.ecr.aws/emr-serverless/spark/emr-7.8.0:20250425-x86_64, since I am building on a Mac, which is an 8-core 2.3GHz Intel Core i9. link default images https://gallery.ecr.aws/emr-serverless/spark/emr-7.8.0 Created an image with no changes:

FROM public.ecr.aws/emr-serverless/spark/emr-7.8.0:20250425-x86_64

USER root

USER hadoop:hadoop

The build script

docker build -t test-emr .

docker run --rm --entrypoint “/bin/bash” test-emr -c “python3 --version”

docker run --rm --entrypoint "/bin/bash" test-emr -c "pip3 list"

The result of the assembly is successful:

Enter image description here

Adding to the application settings:

Enter image description here

Starting the notebook with a verification code:

import sys
import pkg_resources
from pyspark.sql import SparkSession

# Create a Spark Session
spark = (
    SparkSession.builder.appName("Python Spark SQL basic example")
    .getOrCreate()
)

# Print the Python version
print(f"Python version: {sys.version}")

# Print the list of installed packages
print("\nInstalled Python packages:")
for dist in pkg_resources.working_set:
    print(f"{dist.project_name}=={dist.version}")

Result of execution: Enter image description here

Result of the same code without changing the images

Enter image description here

What am I doing wrong?

Also notify aws support team that Python 3.9 version will be deprecated 2025-10, if they are reading

Enter image description here

asked a year ago497 views

2 Answers
0

Job issues: If your job fails when you run a custom image, then check the complete logs in the configured logging destination. If logs aren't available, then check the following configurations:

  1. The base image for the custom image has the same type (Spark or Hive), Amazon EMR Serverless version, and architecture (x86_64/arm_64).
  2. The custom image didn't change Amazon EMR to include jars or binary files.
  3. The custom image environment variables, such as JAVA_HOME or SPARK_HOME, aren't changed.

I would request you to validate the image compatibility. Ensure that the base image you're using (public.ecr.aws/emr-serverless/spark/emr-7.8.0:20250425-x86_64) is compatible with your EMR Serverless application version. EMR Serverless provides an offline tool that can statically check your custom image to validate basic files, environment variables, and correct image configurations.

Image validation: Before using the custom image in your EMR Serverless application, it's recommended to validate it locally. You can use the Amazon EMR Serverless Image CLI tool to do this. However, if you're using a Windows machine, you'll need to run this validation in a Linux environment like Windows Subsystem for Linux (WSL). For more information kindly refer to the official documentation [+] https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/application-custom-image.html#validate

The following table lists the application versions available with EMR Serverless 7.8.0: Application Version Apache Spark 3.5.4 Apache Hive. 3.1.3 Apache Tez 0.10.2

If you want to switch to python 3.10. kindly use the below configuration before you submit the Spark job, set your properties to use the Python virtual environment, as follows.

--conf spark.emr-serverless.driverEnv.PYSPARK_DRIVER_PYTHON=/usr/local/bin/python3.10 --conf spark.emr-serverless.driverEnv.PYSPARK_PYTHON=/usr/local/bin/python3.10 --conf spark.executorEnv.PYSPARK_PYTHON=/usr/local/bin/python3.10

For a comprehensive investigation of this issue, please engage AWS Premium Support, so that we can access and analyze detailed system logs, metrics, and perform advanced diagnostics.

AWS

answered a year ago

-1

Based on the information provided, there are a few potential issues that could be causing your EMR Serverless application to fail when using a custom image:

  1. Image compatibility: Ensure that the base image you're using (public.ecr.aws/emr-serverless/spark/emr-7.8.0:20250425-x86_64) is compatible with your EMR Serverless application version. The image and application versions should match.

  2. Image validation: Before using the custom image in your EMR Serverless application, it's recommended to validate it locally. You can use the Amazon EMR Serverless Image CLI tool to do this. However, if you're using a Windows machine, you'll need to run this validation in a Linux environment like Windows Subsystem for Linux (WSL).

  3. ECR permissions: Make sure that your EMR Serverless application has the necessary permissions to access the ECR repository where your custom image is stored. You may need to update the repository policy to allow the EMR Serverless service principal to perform actions like DescribeImages, BatchGetImage, and GetDownloadUrlForLayer.

  4. Image configuration: Verify that your custom image hasn't inadvertently changed critical environment variables like JAVA_HOME or SPARK_HOME, which could cause issues when running Spark jobs.

  5. Region mismatch: Ensure that the ECR repository containing your custom image is in the same AWS region as your EMR Serverless application.

To troubleshoot further:

  1. Check the complete logs in your configured logging destination for any specific error messages.
  2. Verify that the base image for your custom image has the same type (Spark), EMR Serverless version, and architecture (x86_64) as your application.
  3. Make sure you haven't unintentionally modified any EMR-related files or binaries in your custom image.

Regarding your note about Python 3.9 deprecation, it's a good observation. While it's not directly related to your current issue, it's something the AWS team should be aware of for future planning.

If you continue to face issues after checking these points, you may need to reach out to AWS support for more detailed assistance, as there could be specific configuration or compatibility issues that require closer examination.
Sources
EMR Serverless Custom Image local validation failure | AWS re:Post
Resolve Amazon ECR permission or job issues in Amazon EMR | AWS re:Post
Using custom images with EMR Serverless - Amazon EMR
Troubleshooting AWS CodeBuild - AWS CodeBuild
EMR Serverless service principal is not authorized to perform: ECR:DescribeImages on resource | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.