You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/03/05 09:04:18 UTC

[incubator-linkis] 05/18: 1. linkis-engineconn-manager - add core dump save for engineconn

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.1.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit a55e8776df3fbbdca63d1718383faf29f9246676
Author: alexkun <xu...@qq.com>
AuthorDate: Fri Mar 4 17:49:10 2022 +0800

    1. linkis-engineconn-manager - add core dump save for engineconn
---
 .../apache/linkis/ecm/core/conf/ECPCoreConf.scala  | 26 ++++++++++++++++++++++
 .../core/launch/ProcessEngineCommandBuilder.scala  |  4 ++++
 .../server/operator/EngineConnLogOperator.scala    | 14 +++++-------
 .../impl/ProcessEngineConnLaunchService.scala      |  6 ++---
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/conf/ECPCoreConf.scala b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/conf/ECPCoreConf.scala
new file mode 100644
index 0000000..ce8020d
--- /dev/null
+++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/conf/ECPCoreConf.scala
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.ecm.core.conf
+
+import org.apache.linkis.common.conf.CommonVars
+
+object ECPCoreConf {
+
+  val CORE_DUMP_DISABLE = CommonVars("linkis.ec.core.dump.disable", true).getValue
+
+}
diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineCommandBuilder.scala b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineCommandBuilder.scala
index fd7709b..0bb815d 100644
--- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineCommandBuilder.scala
+++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineCommandBuilder.scala
@@ -65,6 +65,10 @@ class UnixProcessEngineCommandBuilder extends ShellProcessEngineCommandBuilder {
 
   newLine("#!/bin/bash")
 
+  if (ECPCoreConf.CORE_DUMP_DISABLE) {
+    newLine("ulimit -c 0")
+  }
+
   private def addErrorCheck(): Unit = {
     newLine("linkis_engineconn_errorcode=$?")
     newLine("if [ $linkis_engineconn_errorcode -ne 0 ]")
diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
index c446abc..60d6c2d 100644
--- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
+++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
@@ -47,7 +47,7 @@ class EngineConnLogOperator extends Operator with Logging {
     if (lastRows > EngineConnLogOperator.MAX_LOG_FETCH_SIZE.getValue) {
       throw new ECMErrorException(ECMErrorCode.EC_FETCH_LOG_FAILED, s"Cannot fetch more than ${EngineConnLogOperator.MAX_LOG_FETCH_SIZE.getValue} lines of logs.")
     } else if (lastRows > 0) {
-      val logs = Utils.exec(Array("tail", "-f", logPath.getPath), 5000).split("\n")
+      val logs = Utils.exec(Array("tail", "-n", lastRows + "", logPath.getPath), 5000).split("\n")
       return Map("logs" -> logs, "rows" -> logs.length)
     }
     val pageSize = getAs("pageSize", 100)
@@ -103,15 +103,11 @@ class EngineConnLogOperator extends Operator with Logging {
 
   private def includeLine(line: String,
                           onlyKeywordList: Array[String], ignoreKeywordList: Array[String]): Boolean = {
-    if (onlyKeywordList.nonEmpty && onlyKeywordList.exists(line.contains)) {
-      true
-    } else if (ignoreKeywordList.nonEmpty && !ignoreKeywordList.exists(line.contains)) {
-      true
-    } else if (onlyKeywordList.isEmpty && ignoreKeywordList.isEmpty) {
-      true
-    } else {
-      false
+    var accept: Boolean = ignoreKeywordList.isEmpty || !ignoreKeywordList.exists(line.contains)
+    if (accept) {
+      accept = onlyKeywordList.isEmpty || onlyKeywordList.exists(line.contains)
     }
+    accept
   }
   private def getLogPath(implicit parameters: Map[String, Any]): File = {
     if (engineConnListService == null) {
diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
index 4651bb6..b796c18 100644
--- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
+++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
@@ -101,9 +101,9 @@ abstract class ProcessEngineConnLaunchService extends AbstractEngineConnLaunchSe
     }
     Utils.tryThrow(Utils.waitUntil(() => engineConn.getStatus != Starting, Duration(timeout, TimeUnit.MILLISECONDS))) {
       case e: TimeoutException =>
-        throw new ECMErrorException(ECMErrorConstants.ECM_ERROR, s"wait for $engineConn initial timeout.")
-      case e: InterruptedException =>
-        throw new ECMErrorException(ECMErrorConstants.ECM_ERROR, s"wait for $engineConn initial interrupted.")
+        throw new ECMErrorException(ECMErrorCode.EC_START_TIME_OUT, s"wait for engineConn initial timeout(请求引擎超时,可能是因为队列资源不足导致,请重试) $engineConn .")
+      case e: InterruptedException => //比如被ms cancel
+        throw new ECMErrorException(ECMErrorCode.EC_INTERRUPT_TIME_OUT, s"wait for initial interrupted(请求引擎被中断,可能是因为你操作了引擎取消操作,请重试) $engineConn .")
       case t: Throwable =>
         logger.error(s"unexpected error, now shutdown it.")
         throw t

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org