wForget commented on code in PR #6008:
URL: https://github.com/apache/kyuubi/pull/6008#discussion_r1477917098


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala:
##########
@@ -255,24 +260,44 @@ private[v1] class AdminResource extends ApiRequestContext 
with Logging {
     }
     val engine = normalizeEngineInfo(userName, engineType, shareLevel, 
subdomain, "default")
     val engineSpace = calculateEngineSpace(engine)
+    var msg = s"Engine $engineSpace is deleted successfully."
+    if (forceKill) {
+      if (StringUtils.isBlank(refId)) {
+        error(s"Invalid refId: $refId")
+        throw new NotFoundException(s"Invalid refId: $refId")

Review Comment:
   change to `IllegalArgumentException`



##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala:
##########
@@ -255,24 +260,44 @@ private[v1] class AdminResource extends ApiRequestContext 
with Logging {
     }
     val engine = normalizeEngineInfo(userName, engineType, shareLevel, 
subdomain, "default")
     val engineSpace = calculateEngineSpace(engine)
+    var msg = s"Engine $engineSpace is deleted successfully."
+    if (forceKill) {
+      if (StringUtils.isBlank(refId)) {
+        error(s"Invalid refId: $refId")
+        throw new NotFoundException(s"Invalid refId: $refId")
+      }
 
-    withDiscoveryClient(fe.getConf) { discoveryClient =>
-      val engineNodes = discoveryClient.getChildren(engineSpace)
-      engineNodes.foreach { node =>
-        val nodePath = s"$engineSpace/$node"
-        info(s"Deleting engine node:$nodePath")
-        try {
-          discoveryClient.delete(nodePath)
-        } catch {
-          case e: Exception =>
-            error(s"Failed to delete engine node:$nodePath", e)
-            throw new NotFoundException(s"Failed to delete engine 
node:$nodePath," +
-              s"${e.getMessage}")
+      val applicationManagerInfo = ApplicationManagerInfo(
+        Option(sparkMaster),
+        Option(sparK8Context),
+        Option(sparK8Namespace))
+
+      var killMessage: KillResponse = (false, "UNKNOWN")
+      killMessage = fe.be.sessionManager.asInstanceOf[KyuubiSessionManager]
+        .applicationManager.killApplication(applicationManagerInfo, refId)
+      if (!killMessage._1) {
+        msg = s"Engine $engineSpace failed to get deleted forcibly," +
+          s"cause ${killMessage._2}"
+        error(msg)

Review Comment:
   Do we need to throw an exception if kill fails?



##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala:
##########
@@ -255,24 +260,44 @@ private[v1] class AdminResource extends ApiRequestContext 
with Logging {
     }
     val engine = normalizeEngineInfo(userName, engineType, shareLevel, 
subdomain, "default")
     val engineSpace = calculateEngineSpace(engine)
+    var msg = s"Engine $engineSpace is deleted successfully."
+    if (forceKill) {
+      if (StringUtils.isBlank(refId)) {
+        error(s"Invalid refId: $refId")

Review Comment:
   remove this log



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