EMR Cluster: AutoScaling Policy For Instance Group Could Not Attach And Failed

Viewed 304

I am trying to automate the EMR cluster creation through boto3. Unfortunately, I'm getting the following warning:

The Auto Scaling policy for instance group ig-MI0ANZ0C3WNN in Amazon EMR cluster j-BS3Y2OAO65R6 (qidv2_historical_3.0.1) could not attach and failed at 2021-09-20 17:41 UTC.

I cannot figure out what is the issue is. This was adapted from an aws cli command which didn't raise any warnings or issues, but after transitioning to boto3, was getting this autoscaling policy warning

  cluster_id = self.boto_client().run_job_flow(
            Name=self.cluster_name,
            LogUri='s3n://aws-logs',
            JobFlowRole='EMR_EC2_DefaultRole',
            ReleaseLabel=self.release_label,
            Applications=[{'Name': 'Spark'},{'Name': 'Hive'},{'Name': 'Hadoop'},{'Name': 'Pig'},{'Name': 'Hue'},
                          {'Name': 'Zeppelin'},{'Name': 'Livy'},{'Name': 'JupyterHub'},{'Name': 'Tensorflow'}
                          ],
            AutoScalingRole='EMR_AutoScaling_DefaultRole',
            BootstrapActions=[
                {
                    'Name': 'Custom action',
                    'ScriptBootstrapAction': {
                        'Path': 's3://ml-data/emr-bootstrap_spk3.0.1.sh'
                    }
                }
            ],
            ServiceRole='EMR_DefaultRole',
            ScaleDownBehavior='TERMINATE_AT_TASK_COMPLETION',
            EbsRootVolumeSize=25,
            Steps=[
                {
                    'Name': 'Setup Debugging',
                    'ActionOnFailure': 'TERMINATE_CLUSTER',
                    'HadoopJarStep': {
                        'Jar': 'command-runner.jar',
                        'Args': ['state-pusher-script']
                    }
                },

                {
                    'Name': 'Setup - Sync with S3',
                    'ActionOnFailure': 'CANCEL_AND_WAIT',
                    'HadoopJarStep': {
                        'Jar': 'command-runner.jar',
                        'Args': ['aws', 's3', 'sync',
                                 's3://ch-ml-data/',
                                 '/mnt/src/']
                    }
                },

                {
                    'Name': 'Spark Application',
                    'ActionOnFailure': 'CANCEL_AND_WAIT',
                    'HadoopJarStep': {
                        'Jar': 'command-runner.jar',
                        'Args': ['cd /mnt/src; bash spark_jobs/qid_pipeline_historical_run.sh']
                    }
                }
            ],
            Configurations=[
                {
                    'Classification': 'zeppelin-env',
                    'Properties': {},
                    'Configurations': [
                        {
                            'Classification': 'export',
                            'Properties': {
                                'ZEPPELIN_PORT': '8890',
                                'HADOOP_CONF_DIR': '/etc/hadoop/conf',
                                'ZEPPELIN_LOG_DIR': '/var/log/zeppelin',
                                'ZEPPELIN_PID': '$ZEPPELIN_PID_DIR/zeppelin.pid',
                                'MASTER': 'yarn-client',
                                'SPARK_SUBMIT_OPTIONS': "$SPARK_SUBMIT_OPTIONS --conf '\''spark.executorEnv.PYTHONPATH=/usr/lib/spark/python/lib/py4j-src.zip:/usr/lib/spark/python/:<CPS>{{PWD}}/pyspark.zip<CPS>{{PWD}}/py4j-src.zip'\'' --conf spark.yarn.isPython=true",
                                'PYSPARK_DRIVER_PYTHON': '/mnt/anaconda3/envs/question-identification-v2/bin/python',
                                'ZEPPELIN_NOTEBOOK_USER': 'user',
                                'CLASSPATH': ':/usr/lib/hadoop-lzo/lib/*:/usr/lib/hadoop/hadoop-aws.jar:/usr/share/java/Hive-JSON-Serde/hive-openx-serde.jar:/usr/share/aws/aws-java-sdk/*:/usr/share/aws/emr/emrfs/conf:/usr/share/aws/emr/emrfs/lib/*:/usr/share/aws/emr/emrfs/auxlib/*:/usr/share/aws/hmclient/lib/aws-glue-datacatalog-spark-client.jar:/usr/share/aws/sagemaker-spark-sdk/lib/sagemaker-spark-sdk.jar',
                                'ZEPPELIN_PID_DIR': '/var/run/zeppelin',
                                'PYSPARK_PYTHON': '/mnt/anaconda3/envs/question-identification-v2/bin/python',
                                'SPARK_HOME': '/usr/lib/spark',
                                'ZEPPELIN_NOTEBOOK_S3_BUCKET': 'ch-ml-data',
                                'ZEPPELIN_WAR_TEMPDIR': '/var/run/zeppelin/webapps',
                                'ZEPPELIN_CONF_DIR': '/etc/zeppelin/conf',
                                'ZEPPELIN_NOTEBOOK_STORAGE': 'org.apache.zeppelin.notebook.repo.S3NotebookRepo',
                                'ZEPPELIN_NOTEBOOK_DIR': '/var/lib/zeppelin/notebook',
                                'ZEPPELIN_ADDR': '0.0.0.0'
                            }
                        }
                    ]
                },
                {
                    'Classification': 'hive-site',
                    'Properties': {
                        'hive.metastore.client.factory.class': 'com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory'
                    }
                },
                {
                    'Classification': 'spark-hive-site',
                    'Properties': {
                        'hive.metastore.client.factory.class': 'com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory'
                    }
                }
            ],
            Instances={
                'Ec2KeyName': 'emr-temporary',
                'KeepJobFlowAliveWhenNoSteps': False,
                'TerminationProtected': False,
                'Ec2SubnetId': 'subnet-063735e4fa63e3bac',
                'AdditionalSlaveSecurityGroups': ["sg-012970517d0a88bae", "sg-01813cf2115b55874", "sg-04563fc7e8ed9e1ec", "sg-07ab30655981361ad"],
                'ServiceAccessSecurityGroup': 'sg-00dd6e63d7004176d',
                'EmrManagedSlaveSecurityGroup': 'sg-048b83d1a20550b43',
                'EmrManagedMasterSecurityGroup': 'sg-017402b74e879aaa5',
                'AdditionalMasterSecurityGroups': ["sg-012970517d0a88bae", "sg-01813cf2115b55874", "sg-04563fc7e8ed9e1ec", "sg-07ab30655981361ad"],
                'InstanceGroups': [
                    {
                        'Name': 'Task',
                        'InstanceRole': 'TASK',
                        'InstanceType': 'i3.2xlarge',
                        'InstanceCount': 1
                    },
                    {
                        'Name': 'Master - 1',
                        'InstanceRole': 'MASTER',
                        'InstanceType': 'i3.2xlarge',
                        'InstanceCount': 1,
                    },
                    {
                        'Name': 'Core - 2',
                        'InstanceRole': 'CORE',
                        'InstanceType': 'i3.2xlarge',
                        'InstanceCount': 1,
                        'Market': 'SPOT',
                        'AutoScalingPolicy': {
                            'Constraints': {
                                'MinCapacity': 3,
                                'MaxCapacity': 100
                            },
                            'Rules': [
                                {
                                    'Name': 'memory',
                                    'Description': '',
                                    'Action': {
                                        'SimpleScalingPolicyConfiguration': {
                                            'ScalingAdjustment': 10,
                                            'CoolDown': 300,
                                            'AdjustmentType': 'CHANGE_IN_CAPACITY'
                                        }
                                    },
                                    'Trigger': {
                                        'CloudWatchAlarmDefinition': {
                                            'MetricName': 'YARNMemoryAvailablePercentage',
                                            'ComparisonOperator': 'LESS_THAN',
                                            'Statistic': 'AVERAGE',
                                            'Period': 300,
                                            'EvaluationPeriods': 2,
                                            'Unit': 'PERCENT',
                                            'Namespace': 'AWS/ElasticMapReduce',
                                            'Threshold': 25,
                                            'Dimensions': [
                                                {
                                                    'Value': '${emr.clusterId}',
                                                    'Key': 'JobFlowId'
                                                 }
                                            ]
                                        }
                                    }
                                },

                                {
                                    'Name': 'mem',
                                    'Description': '',
                                    'Action': {
                                        'SimpleScalingPolicyConfiguration': {
                                            'ScalingAdjustment': -5,
                                            'CoolDown': 300,
                                            'AdjustmentType': 'CHANGE_IN_CAPACITY'
                                        }
                                    },
                                    'Trigger': {
                                        'CloudWatchAlarmDefinition': {
                                            'MetricName': 'YARNMemoryAvailablePercentage',
                                            'ComparisonOperator': 'GREATER_THAN_OR_EQUAL',
                                            'Statistic': 'AVERAGE',
                                            'Period': 300,
                                            'EvaluationPeriods': 18,
                                            'Unit': 'PERCENT',
                                            'Namespace': 'AWS/ElasticMapReduce',
                                            'Threshold': 50,
                                            'Dimensions': [
                                                {
                                                    'Value': '${emr.clusterId}',
                                                    'Key': 'JobFlowId'
                                                }
                                            ],
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        )
0 Answers
Related