abellina commented on a change in pull request #25403: [SPARK-28679][YARN] 
changes to setResourceInformation to handle empty resources and reflection 
error handling
URL: https://github.com/apache/spark/pull/25403#discussion_r314310736
 
 

 ##########
 File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ResourceRequestHelper.scala
 ##########
 @@ -143,17 +143,29 @@ private object ResourceRequestHelper extends Logging {
     require(resource != null, "Resource parameter should not be null!")
 
     logDebug(s"Custom resources requested: $resources")
+    if (resources.isEmpty) {
+      // no point in going forward, as we don't have anything to set
+      return
+    }
+
     if (!isYarnResourceTypesAvailable()) {
-      if (resources.nonEmpty) {
-        logWarning("Ignoring custom resource requests because " +
-            "the version of YARN does not support it!")
-      }
+      logWarning("Ignoring custom resource requests because " +
+          "the version of YARN does not support it!")
       return
     }
 
     val resInfoClass = Utils.classForName(RESOURCE_INFO_CLASS)
     val setResourceInformationMethod =
-      resource.getClass.getMethod("setResourceInformation", classOf[String], 
resInfoClass)
+      try {
+        resource.getClass.getMethod("setResourceInformation", classOf[String], 
resInfoClass)
+      } catch {
+        case e: NoSuchMethodException =>
+          throw new SparkException(
+            s"""Cannot find $RESOURCE_INFO_CLASS.setResourceInformation.
+                |This is likely due to a jar conflict between different yarn 
versions."""
+                .stripMargin.replace("\n", " "), e)
 
 Review comment:
   @dongjoon-hyun I changed this, sorry for the delay.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to