title: Mark Spark Job as Failed in Yarn UI
body: <p>The application is part of complex eco-system, where we are tracking status of all jobs using Yarn Rest Api.</p>
  
  <p>Now for some specific business scenario we need to mark Spark Job as failed, but I have landed in a Gotcha situation, because doesn't matter what I raise in spark job Error/Exception or System.exit(123) job gets marked as Finished in Yarn, with finalstatus as Succeeded.</p>
  
  <p>Using spark-submit to fire the spark job using jar.</p>
  
  <pre><code>object Execute {
   def main(args: Array[String]) {
     val sc = new SparkContext(sparkConf)
     if(businessException needs to be raised)
        //What to do???
   }
  }
  </code></pre>
  
  <p>Things I have tried in spark job:</p>
  
  <ul>
  <li>throw new Error("Whatever")</li>
  <li>throw new Exception("Whatever")</li>
  <li>System.exit(123)</li>
  <li>sys.exit(123)</li>
  </ul>
  
  <p>Hopefully someone can tell me how do I mark spark job as failed in yarn UI.</p>