Skip to content

spark env issues post custom ami creation for EMR on EC2 cluster stuck in steps failure

0

Hello,

Getting issues post custom ami use at EMR on Ec2 cluster with spark submit resulted in failure

	0 artifacts copied, 60 already retrieved (0kB/30ms)
25/01/23 13:11:37 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: Class com.amazon.ws.emr.hadoop.fs.EmrFileSystem not found

If I set source /etc/spark/conf/spark-env.sh and then submit spark jobs on EMR master machine it works without any error, If I use step function to submit spark jobs it fails as it is missing source /etc/spark/conf/spark-env.sh before running spark steps.

Made custom ami to upgrade python to 3.8 from python 3.7 with EMR 6.10.0 release and observed that jars were absent post custom AMI usage with EMR at /usr/lib/spark/jars/

Any solution,?? help?

asked 2 years ago308 views

1 Answer
0

The issue you're experiencing is likely related to the custom AMI creation process and its impact on the Spark environment configuration. When you create a custom AMI for EMR, especially when upgrading components like Python, it's important to ensure that all necessary environment variables and configurations are properly set.

The error message suggests that the EMR File System (EMRFS) class is not being found when submitting Spark jobs through the step function. This is likely because the custom AMI creation process has altered the default environment setup.

To resolve this issue, you have a few options:

  1. Bootstrap Action: You can create a bootstrap action script that sources the Spark environment file before running any Spark jobs. Add this bootstrap action when creating your EMR cluster:

    #!/bin/bash
    sudo tee -a /etc/spark/conf/spark-env.sh << EOL
    source /etc/spark/conf/spark-env.sh
    EOL
    
  2. Custom Step Script: Instead of directly using spark-submit in your step function, create a wrapper script that sources the Spark environment file before running the Spark job. Your step would then call this wrapper script instead.

  3. Modify EMR Configuration: You can try to set the Spark classpath explicitly in the EMR configuration when creating the cluster. Add a configuration like this:

    [
      {
        "Classification": "spark-env",
        "Properties": {},
        "Configurations": [
          {
            "Classification": "export",
            "Properties": {
              "SPARK_CLASSPATH": "/usr/lib/spark/jars/*:/usr/share/aws/emr/emrfs/lib/*"
            }
          }
        ]
      }
    ]
    
  4. Review Custom AMI Process: Ensure that your custom AMI creation process is not inadvertently removing or modifying critical EMR configurations. You may need to manually copy over some configuration files from the base EMR AMI to your custom AMI.

Remember, when creating a custom AMI for EMR, it's crucial to maintain compatibility with EMR's expected environment. Always test thoroughly after making changes to ensure all components work as expected.
Sources
Manual submitted step jobs failing | AWS re:Post
Spark application specifics with earlier AMI versions of Amazon EMR - Amazon EMR
EMR Cluster failure with "Failed to start the job flow due to an internal error" | AWS re:Post
ClassNotFoundException EmrFileSystem error while setting Spark --driver-class-path config in EMR Serverless | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years 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.