By default, the maximum number of times to submit the application is set to the property yarn.resourcemanager.am.max-attempts
If you want to change this, refer to the below command:
val sc = new SparkContext(new SparkConf())
./bin/spark-submit <all your existing options> --spark.yarn.maxAppAttempts= <max number of attempt>