You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/02/23 03:46:08 UTC
[kyuubi] branch master updated: [KYUUBI #4397] [BUILD] `build/dist` supports `--web-ui`
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new fafd017df [KYUUBI #4397] [BUILD] `build/dist` supports `--web-ui`
fafd017df is described below
commit fafd017df53bbd529f49b3d7c036363711d8ee02
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Thu Feb 23 11:45:58 2023 +0800
[KYUUBI #4397] [BUILD] `build/dist` supports `--web-ui`
### _Why are the changes needed?_
```
Usage:
+----------------------------------------------------------------------------------------------+
| ./build/dist [--name <custom_name>] [--tgz] [--web-ui] [--flink-provided] [--hive-provided] |
| [--spark-provided] [--mvn <maven_executable>] <maven build options> |
+----------------------------------------------------------------------------------------------+
name: - custom binary name, using project version if undefined
tgz: - whether to make a whole bundled package
web-ui: - whether to include web ui
flink-provided: - whether to make a package without Flink binary
hive-provided: - whether to make a package without Hive binary
spark-provided: - whether to make a package without Spark binary
mvn: - external maven executable location
```
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [x] Add screenshots for manual tests if appropriate
Create binary artifacts using `build/dist --tgz --web-ui` and run, then open `http://0.0.0.0:10099/ui`
<img width="1401" alt="image" src="https://user-images.githubusercontent.com/26535726/220753103-ce801f12-f394-4ece-92a4-1902e93c62c7.png">
- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #4397 from pan3793/webui-build.
Closes #4397
97901d63e [Cheng Pan] doc
37d5e2ad3 [Cheng Pan] mirror-cdn
c5751dd5b [Cheng Pan] remove unused dep
d308defb7 [Cheng Pan] nit
9abca4705 [Cheng Pan] nit
c1d184afd [Cheng Pan] nit
7091d5bf5 [Cheng Pan] regex
f0ac16b3c [Cheng Pan] [BUILD] `build/dist` support --web-ui
Authored-by: Cheng Pan <ch...@apache.org>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
.gitignore | 1 +
.rat-excludes | 2 ++
bin/kyuubi | 16 ++++++---
build/dist | 25 ++++++++++---
build/release/create-package.sh | 2 +-
docs/develop_tools/distribution.md | 11 +++---
kyuubi-server/pom.xml | 41 ++++++++++++++++++++++
.../{web-ui => src/main/resources/dist}/index.html | 7 ++--
.../kyuubi/server/KyuubiRestFrontendService.scala | 18 ++++++++--
.../http/authentication/AuthenticationFilter.scala | 1 -
kyuubi-server/web-ui/.gitignore | 1 +
kyuubi-server/web-ui/README.md | 2 +-
kyuubi-server/web-ui/index.html | 2 +-
kyuubi-server/web-ui/package-lock.json | 4 +--
kyuubi-server/web-ui/package.json | 2 +-
kyuubi-server/web-ui/src/router/index.ts | 2 +-
kyuubi-server/web-ui/vite.config.ts | 1 +
pom.xml | 30 +++++++++++++++-
18 files changed, 137 insertions(+), 31 deletions(-)
diff --git a/.gitignore b/.gitignore
index bb2df4fd0..9a115ab0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ hs_err_pid*
spark-warehouse/
metastore_db
derby.log
+rest-audit.log
**/dependency-reduced-pom.xml
metrics/report.json
metrics/.report.json.crc
diff --git a/.rat-excludes b/.rat-excludes
index 2906e7cea..7a841cf9c 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -51,6 +51,8 @@ build/scala-*/**
**/metadata-store-schema*.sql
**/*.derby.sql
**/*.mysql.sql
+**/node/**
+**/web-ui/dist/**
**/pnpm-lock.yaml
**/node_modules/**
**/gen/*
diff --git a/bin/kyuubi b/bin/kyuubi
index 414bdeb86..09c8e9373 100755
--- a/bin/kyuubi
+++ b/bin/kyuubi
@@ -87,10 +87,18 @@ if [[ -z "$KYUUBI_JAR_DIR" ]]; then
fi
fi
-if [[ -z ${YARN_CONF_DIR} ]]; then
- KYUUBI_CLASSPATH="${KYUUBI_JAR_DIR}/*:${KYUUBI_CONF_DIR}:${HADOOP_CONF_DIR}"
-else
- KYUUBI_CLASSPATH="${KYUUBI_JAR_DIR}/*:${KYUUBI_CONF_DIR}:${HADOOP_CONF_DIR}:${YARN_CONF_DIR}"
+## Find the WebUI dist
+if [[ -z "$KYUUBI_WEBUI_DIR" ]]; then
+ KYUUBI_WEBUI_DIR="$KYUUBI_HOME/web-ui"
+ if [[ ! -d ${KYUUBI_WEBUI_DIR} ]]; then
+ echo -e "\nCandidate Kyuubi WebUI dist $KYUUBI_WEBUI_DIR doesn't exist, searching development environment..."
+ KYUUBI_WEBUI_DIR="$KYUUBI_HOME/kyuubi-server/web-ui"
+ fi
+fi
+
+KYUUBI_CLASSPATH="${KYUUBI_CONF_DIR}:${KYUUBI_WEBUI_DIR}:${KYUUBI_JAR_DIR}/*:${HADOOP_CONF_DIR}"
+if [[ -n ${YARN_CONF_DIR} ]]; then
+ KYUUBI_CLASSPATH="${KYUUBI_CLASSPATH}:${YARN_CONF_DIR}"
fi
cmd="${RUNNER} ${KYUUBI_JAVA_OPTS} -cp ${KYUUBI_CLASSPATH} $CLASS"
diff --git a/build/dist b/build/dist
index 7b51886df..0620c7d08 100755
--- a/build/dist
+++ b/build/dist
@@ -31,6 +31,7 @@ set -x
KYUUBI_HOME="$(cd "`dirname "$0"`/.."; pwd)"
DISTDIR="$KYUUBI_HOME/dist"
MAKE_TGZ=false
+ENABLE_WEBUI=false
FLINK_PROVIDED=false
SPARK_PROVIDED=false
HIVE_PROVIDED=false
@@ -42,15 +43,16 @@ function usage {
echo "./build/dist - Tool for making binary distributions of Kyuubi"
echo ""
echo "Usage:"
- echo "+------------------------------------------------------------------------------------------------------+"
- echo "| ./build/dist [--name <custom_name>] [--tgz] [--flink-provided] [--spark-provided] [--hive-provided] |"
- echo "| [--mvn <maven_executable>] <maven build options> |"
- echo "+------------------------------------------------------------------------------------------------------+"
+ echo "+----------------------------------------------------------------------------------------------+"
+ echo "| ./build/dist [--name <custom_name>] [--tgz] [--web-ui] [--flink-provided] [--hive-provided] |"
+ echo "| [--spark-provided] [--mvn <maven_executable>] <maven build options> |"
+ echo "+----------------------------------------------------------------------------------------------+"
echo "name: - custom binary name, using project version if undefined"
echo "tgz: - whether to make a whole bundled package"
+ echo "web-ui: - whether to include web ui"
echo "flink-provided: - whether to make a package without Flink binary"
- echo "spark-provided: - whether to make a package without Spark binary"
echo "hive-provided: - whether to make a package without Hive binary"
+ echo "spark-provided: - whether to make a package without Spark binary"
echo "mvn: - external maven executable location"
echo ""
}
@@ -67,6 +69,9 @@ while (( "$#" )); do
--tgz)
MAKE_TGZ=true
;;
+ --web-ui)
+ ENABLE_WEBUI=true
+ ;;
--flink-provided)
FLINK_PROVIDED=true
;;
@@ -212,6 +217,10 @@ fi
MVN_DIST_OPT="-DskipTests"
+if [[ "$ENABLE_WEBUI" == "true" ]]; then
+ MVN_DIST_OPT="$MVN_DIST_OPT -Pweb-ui"
+fi
+
if [[ "$SPARK_PROVIDED" == "true" ]]; then
MVN_DIST_OPT="$MVN_DIST_OPT -Pspark-provided"
fi
@@ -321,6 +330,12 @@ for SPARK_EXTENSION_VERSION in ${SPARK_EXTENSION_VERSIONS[@]}; do
fi
done
+if [[ "$ENABLE_WEBUI" == "true" ]]; then
+ # Copy web ui dist
+ mkdir -p "$DISTDIR/web-ui"
+ cp -r "$KYUUBI_HOME/kyuubi-server/web-ui/dist" "$DISTDIR/web-ui/"
+fi
+
if [[ "$FLINK_PROVIDED" != "true" ]]; then
# Copy flink binary dist
FLINK_BUILTIN="$(find "$KYUUBI_HOME/externals/kyuubi-download/target" -name 'flink-*' -type d)"
diff --git a/build/release/create-package.sh b/build/release/create-package.sh
index c98e7c0f8..28a89165e 100755
--- a/build/release/create-package.sh
+++ b/build/release/create-package.sh
@@ -75,7 +75,7 @@ package_binary() {
echo "Creating binary release tarball ${BIN_TGZ_FILE}"
- ${KYUUBI_DIR}/build/dist --tgz --spark-provided --flink-provided --hive-provided
+ ${KYUUBI_DIR}/build/dist --tgz --web-ui --spark-provided --flink-provided --hive-provided
cp "${BIN_TGZ_FILE}" "${RELEASE_DIR}"
diff --git a/docs/develop_tools/distribution.md b/docs/develop_tools/distribution.md
index abc2ac91b..217f0a417 100644
--- a/docs/develop_tools/distribution.md
+++ b/docs/develop_tools/distribution.md
@@ -26,15 +26,16 @@ For more information on usage, run `./build/dist --help`
./build/dist - Tool for making binary distributions of Kyuubi
Usage:
-+------------------------------------------------------------------------------------------------------+
-| ./build/dist [--name <custom_name>] [--tgz] [--flink-provided] [--spark-provided] [--hive-provided] |
-| [--mvn <maven_executable>] <maven build options> |
-+------------------------------------------------------------------------------------------------------+
++----------------------------------------------------------------------------------------------+
+| ./build/dist [--name <custom_name>] [--tgz] [--web-ui] [--flink-provided] [--hive-provided] |
+| [--spark-provided] [--mvn <maven_executable>] <maven build options> |
++----------------------------------------------------------------------------------------------+
name: - custom binary name, using project version if undefined
tgz: - whether to make a whole bundled package
+web-ui: - whether to include web ui
flink-provided: - whether to make a package without Flink binary
-spark-provided: - whether to make a package without Spark binary
hive-provided: - whether to make a package without Hive binary
+spark-provided: - whether to make a package without Spark binary
mvn: - external maven executable location
```
diff --git a/kyuubi-server/pom.xml b/kyuubi-server/pom.xml
index 53b8a9601..aebce5dda 100644
--- a/kyuubi-server/pom.xml
+++ b/kyuubi-server/pom.xml
@@ -543,6 +543,47 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <configuration>
+ <workingDirectory>web-ui</workingDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>install node and pnpm</id>
+ <goals>
+ <goal>install-node-and-pnpm</goal>
+ </goals>
+ <configuration>
+ <skip>${webui.skip}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pnpm install</id>
+ <goals>
+ <goal>pnpm</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <skip>${webui.skip}</skip>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pnpm run build</id>
+ <goals>
+ <goal>pnpm</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <skip>${webui.skip}</skip>
+ <arguments>run build</arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
<testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>
diff --git a/kyuubi-server/web-ui/index.html b/kyuubi-server/src/main/resources/dist/index.html
similarity index 77%
copy from kyuubi-server/web-ui/index.html
copy to kyuubi-server/src/main/resources/dist/index.html
index bd4f50672..ab54fc14a 100644
--- a/kyuubi-server/web-ui/index.html
+++ b/kyuubi-server/src/main/resources/dist/index.html
@@ -20,12 +20,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Vite + Vue + TS</title>
+ <title>Apache Kyuubi Dashboard</title>
</head>
<body>
- <div id="app"></div>
- <script type="module" src="/src/main.ts"></script>
+ <div>This is a dummy page for development.</div>
</body>
</html>
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
index 29f4cf304..7019d8a6a 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
@@ -26,14 +26,14 @@ import javax.ws.rs.core.Response.Status
import com.google.common.annotations.VisibleForTesting
import org.apache.hadoop.conf.Configuration
-import org.eclipse.jetty.servlet.FilterHolder
+import org.eclipse.jetty.servlet.{ErrorPageErrorHandler, FilterHolder}
import org.apache.kyuubi.{KyuubiException, Utils}
import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.config.KyuubiConf.{FRONTEND_REST_BIND_HOST, FRONTEND_REST_BIND_PORT, FRONTEND_REST_MAX_WORKER_THREADS, METADATA_RECOVERY_THREADS}
+import org.apache.kyuubi.config.KyuubiConf._
import org.apache.kyuubi.server.api.v1.ApiRootResource
import org.apache.kyuubi.server.http.authentication.{AuthenticationFilter, KyuubiHttpAuthenticationFactory}
-import org.apache.kyuubi.server.ui.JettyServer
+import org.apache.kyuubi.server.ui.{JettyServer, JettyUtils}
import org.apache.kyuubi.service.{AbstractFrontendService, Serverable, Service, ServiceUtils}
import org.apache.kyuubi.service.authentication.KyuubiAuthenticationFactory
import org.apache.kyuubi.session.{KyuubiSessionManager, SessionHandle}
@@ -95,6 +95,18 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
server.addRedirectHandler("/docs", "/swagger/")
server.addRedirectHandler("/docs/", "/swagger/")
server.addRedirectHandler("/swagger", "/swagger/")
+
+ installWebUI()
+ }
+
+ private def installWebUI(): Unit = {
+ val servletHandler = JettyUtils.createStaticHandler("dist", "/ui")
+ // HTML5 Web History Mode requires redirect any url path under Web UI Servlet to the main page.
+ // See more details at https://router.vuejs.org/guide/essentials/history-mode.html#html5-mode
+ val errorHandler = new ErrorPageErrorHandler
+ errorHandler.addErrorPage(404, "/")
+ servletHandler.setErrorHandler(errorHandler)
+ server.addHandler(servletHandler)
}
private def startBatchChecker(): Unit = {
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/AuthenticationFilter.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/AuthenticationFilter.scala
index 740937d8e..3c4065a7b 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/AuthenticationFilter.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/http/authentication/AuthenticationFilter.scala
@@ -79,7 +79,6 @@ class AuthenticationFilter(conf: KyuubiConf) extends Filter with Logging {
override def init(filterConfig: FilterConfig): Unit = {
initAuthHandlers()
- super.init(filterConfig)
}
private[kyuubi] def getMatchedHandler(authorization: String): Option[AuthenticationHandler] = {
diff --git a/kyuubi-server/web-ui/.gitignore b/kyuubi-server/web-ui/.gitignore
index be5bdb236..c6cab4b86 100644
--- a/kyuubi-server/web-ui/.gitignore
+++ b/kyuubi-server/web-ui/.gitignore
@@ -14,6 +14,7 @@
# limitations under the License.
.DS_Store
+node
node_modules
/dist
/coverage
diff --git a/kyuubi-server/web-ui/README.md b/kyuubi-server/web-ui/README.md
index 6d808ecde..f93373414 100644
--- a/kyuubi-server/web-ui/README.md
+++ b/kyuubi-server/web-ui/README.md
@@ -15,7 +15,7 @@ npm install
### Development Project
-To do this you can change the VITE_APP_DEV_WEB_URL parameter variable as the service url in `.env.development` in the project root directory, such as http://127.0. 0.1:8090
+To do this you can change the VITE_APP_DEV_WEB_URL parameter variable as the service url in `.env.development` in the project root directory, such as http://127.0.0.1:8090
```shell
npm run dev
diff --git a/kyuubi-server/web-ui/index.html b/kyuubi-server/web-ui/index.html
index bd4f50672..2c4579eb0 100644
--- a/kyuubi-server/web-ui/index.html
+++ b/kyuubi-server/web-ui/index.html
@@ -22,7 +22,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Vite + Vue + TS</title>
+ <title>Apache Kyuubi Dashboard</title>
</head>
<body>
<div id="app"></div>
diff --git a/kyuubi-server/web-ui/package-lock.json b/kyuubi-server/web-ui/package-lock.json
index 77a3991e5..0a2feeba1 100644
--- a/kyuubi-server/web-ui/package-lock.json
+++ b/kyuubi-server/web-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "kyuubi-ui",
- "version": "1.7.0-SNAPSHOT",
+ "version": "1.8.0-SNAPSHOT",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "kyuubi-ui",
- "version": "1.7.0-SNAPSHOT",
+ "version": "1.8.0-SNAPSHOT",
"dependencies": {
"@element-plus/icons-vue": "^2.0.9",
"axios": "^0.27.2",
diff --git a/kyuubi-server/web-ui/package.json b/kyuubi-server/web-ui/package.json
index 2ae37cdb9..63fdc7221 100644
--- a/kyuubi-server/web-ui/package.json
+++ b/kyuubi-server/web-ui/package.json
@@ -1,7 +1,7 @@
{
"name": "kyuubi-ui",
"private": true,
- "version": "1.7.0-SNAPSHOT",
+ "version": "1.8.0-SNAPSHOT",
"type": "module",
"scripts": {
"dev": "vue-tsc --noEmit && vite --port 9090",
diff --git a/kyuubi-server/web-ui/src/router/index.ts b/kyuubi-server/web-ui/src/router/index.ts
index 836dbc5d0..207a22d56 100644
--- a/kyuubi-server/web-ui/src/router/index.ts
+++ b/kyuubi-server/web-ui/src/router/index.ts
@@ -44,7 +44,7 @@ const routes = [
]
const router = createRouter({
- history: createWebHistory(),
+ history: createWebHistory('/ui'),
routes
})
diff --git a/kyuubi-server/web-ui/vite.config.ts b/kyuubi-server/web-ui/vite.config.ts
index 1b3e99a12..92af99741 100644
--- a/kyuubi-server/web-ui/vite.config.ts
+++ b/kyuubi-server/web-ui/vite.config.ts
@@ -20,6 +20,7 @@ import Vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig({
+ base: '/ui/',
plugins: [Vue()],
resolve: {
alias: [
diff --git a/pom.xml b/pom.xml
index 1a583eb78..ecb397a03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -202,6 +202,11 @@
<trino.tpch.version>1.1</trino.tpch.version>
<zookeeper.version>3.4.14</zookeeper.version>
+ <!-- webui -->
+ <webui.skip>true</webui.skip>
+ <node.version>v16.19.1</node.version>
+ <pnpm.version>v7.27.1</pnpm.version>
+
<!-- apply to kyuubi-hive-jdbc/kyuubi-hive-beeline module -->
<hive.client.jline.version>2.12</hive.client.jline.version>
<hive.client.supercsv.version>2.2.0</hive.client.supercsv.version>
@@ -215,6 +220,7 @@
<maven.plugin.download.version>1.6.8</maven.plugin.download.version>
<maven.plugin.download.cache.path></maven.plugin.download.cache.path>
<maven.plugin.enforcer.mojo.rules.version>1.6.1</maven.plugin.enforcer.mojo.rules.version>
+ <maven.plugin.frontend.version>1.12.1</maven.plugin.frontend.version>
<maven.plugin.scala.version>4.8.0</maven.plugin.scala.version>
<maven.plugin.surefire.version>3.0.0-M8</maven.plugin.surefire.version>
<maven.plugin.scalatest.version>2.2.0</maven.plugin.scalatest.version>
@@ -1991,6 +1997,9 @@
<fileset>
<directory>${project.basedir}/spark-warehouse</directory>
</fileset>
+ <fileset>
+ <directory>${project.basedir}/web-ui/dist</directory>
+ </fileset>
</filesets>
</configuration>
</plugin>
@@ -2144,6 +2153,16 @@
</dependency>
</dependencies>
</plugin>
+
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>${maven.plugin.frontend.version}</version>
+ <configuration>
+ <nodeVersion>${node.version}</nodeVersion>
+ <pnpmVersion>${pnpm.version}</pnpmVersion>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
@@ -2228,9 +2247,11 @@
<profiles>
<profile>
<id>mirror-cdn</id>
- <!-- this profile works only for latest apache releases -->
<properties>
+ <!-- the apache cdn mirror works only for latest apache releases -->
<apache.archive.dist>https://dlcdn.apache.org</apache.archive.dist>
+ <nodeDownloadRoot>https://npmmirror.com/mirrors/node/</nodeDownloadRoot>
+ <pnpmDownloadRoot>https://registry.npmmirror.com/pnpm/-/</pnpmDownloadRoot>
</properties>
</profile>
@@ -2421,6 +2442,13 @@
</properties>
</profile>
+ <profile>
+ <id>web-ui</id>
+ <properties>
+ <webui.skip>false</webui.skip>
+ </properties>
+ </profile>
+
<profile>
<id>apache-release</id>
<build>