HwangDongJun commented on code in PR #58187:
URL: https://github.com/apache/spark/pull/58187#discussion_r4608821843


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala:
##########
@@ -177,10 +196,36 @@ private[spark] class Client(
       kubernetesClient.resourceList(otherKubernetesResources: 
_*).forceConflicts().serverSideApply()
     } catch {
       case NonFatal(e) =>
-        kubernetesClient.pods().resource(createdDriverPod).delete()
+        Utils.tryLogNonFatalError {
+          kubernetesClient.pods().resource(createdDriverPod).delete()
+        }
         throw e
     }
 
+    // The resources spark-submit creates for the driver exist now, so let the 
scheduler place the
+    // pod. The strategic merge patch names the gate, so it is idempotent and 
leaves other gates
+    // alone.
+    if (gateDriverPod) {
+      try {
+        kubernetesClient.pods().resource(createdDriverPod).patch(
+          PatchContext.of(PatchType.STRATEGIC_MERGE),
+          """{"spec":{"schedulingGates":[""" +
+            
s"""{"$$patch":"delete","name":"$DRIVER_RESOURCES_SCHEDULING_GATE"}]}}""")
+      } catch {
+        case NonFatal(e) =>
+          e match {
+            case ke: KubernetesClientException if ke.getCode == 403 =>
+              logError("Please check \"kubectl auth can-i patch pod\" first. 
It should be yes." +
+                s" Or set ${USE_DRIVER_SCHEDULING_GATE.key} to false.")

Review Comment:
   Done with your suggestion: `log"""Please check "kubectl auth can-i patch 
pod" first. It should be yes."""` followed by `log" Or set ${MDC(CONFIG, 
USE_DRIVER_SCHEDULING_GATE.key)} to false."`, and `CONFIG` is added to the 
`LogKeys` import. The first line was wrapped to stay within 100 columns.
   
   I left `dev/structured_logging_style.py` alone since it is a separate issue.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to