You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/10/11 13:46:47 UTC

[GitHub] [incubator-kyuubi] lightning-L commented on a diff in pull request #3609: [KYUUBI #3410] Support to delete the engine node from engine discovery space with AdminResource

lightning-L commented on code in PR #3609:
URL: https://github.com/apache/incubator-kyuubi/pull/3609#discussion_r992349781


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala:
##########
@@ -53,4 +58,64 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
     KyuubiServer.reloadHadoopConf()
     Response.ok(s"Refresh the hadoop conf for ${fe.connectionUrl} successfully.").build()
   }
+
+  @ApiResponse(
+    responseCode = "200",
+    content = Array(new Content(
+      mediaType = MediaType.APPLICATION_JSON)),
+    description = "delete kyuubi engine")
+  @DELETE
+  @Path("engine")
+  def deleteEngine(
+      @QueryParam("type") engineType: String,
+      @QueryParam("subdomain") engineSubdomain: String,
+      @QueryParam("sharelevel") engineShareLevel: String,
+      @QueryParam("hive.server2.proxy.user") hs2ProxyUser: String): Response = {
+    val sessionConf = Option(hs2ProxyUser).filter(_.nonEmpty).map(proxyUser =>
+      Map(KyuubiAuthenticationFactory.HS2_PROXY_USER -> proxyUser)).getOrElse(Map())
+
+    var userName: String = null
+    try {
+      userName = fe.getUserName(sessionConf)
+    } catch {
+      case t: Throwable =>
+        throw new NotAllowedException(t.getMessage)
+    }
+
+    // use default value from kyuubi conf when param is not provided
+    val normalizedEngineType = Some(engineType)
+      .filter(_ != null).filter(_.nonEmpty)
+      .getOrElse(fe.getConf.get(ENGINE_TYPE))
+    val normalizedEngineSubdomain = Some(engineSubdomain)
+      .filter(_ != null).filter(_.nonEmpty)
+      .getOrElse(fe.getConf.get(ENGINE_SHARE_LEVEL_SUBDOMAIN).getOrElse("default"))

Review Comment:
   I am using
   ```
   val engineSubdomain = Option(subdomain).filter(_.nonEmpty).orElse(fe.getConf.get(ENGINE_SHARE_LEVEL_SUBDOMAIN)).getOrElse("default")
   ```
   
   There will be error for:
   ```
   val engineSubdomain = Option(subdomain).filter(_.nonEmpty).orElse(fe.getConf.get(ENGINE_SHARE_LEVEL_SUBDOMAIN).getOrElse("default"))
   ```
   <img width="732" alt="image" src="https://user-images.githubusercontent.com/21362040/195108260-d06d0af7-11b5-45cf-9b24-b32ae947f927.png">
   Type mismatch:
    Required: Option[NotInferred]
    Found: String
   



-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org