From 5a4e3707cac9ddcc331d5ba933ddd5b51fa2515c Mon Sep 17 00:00:00 2001 From: zhenjiaguo Date: Wed, 1 Dec 2021 18:46:00 +0800 Subject: [PATCH] [KYUUBI #1449] Fix when KyuubiServer initialize fail but not exit ### _Why are the changes needed?_ Kyuubi server should exit when initialize fail. Detail see #1449. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1468 from zhenjiaguo/fix-TBFS-init-fail-not-exit. Closes #1449 4467a249 [zhenjiaguo] add status judgment before zkServer stop 4208663e [zhenjiaguo] stop zkServer when kyuubi server init fail 1ff3a825 [zhenjiaguo] try catch server initialize Authored-by: zhenjiaguo Signed-off-by: Kent Yao --- .../scala/org/apache/kyuubi/server/KyuubiServer.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiServer.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiServer.scala index 2d200c4cc93..3196f69ef0f 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiServer.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiServer.scala @@ -90,7 +90,15 @@ object KyuubiServer extends Logging { } val server = new KyuubiServer() - server.initialize(conf) + try { + server.initialize(conf) + } catch { + case e: Exception => + if (zkServer.getServiceState == ServiceState.STARTED) { + zkServer.stop() + } + throw e + } server.start() Utils.addShutdownHook(() => server.stop(), Utils.SERVER_SHUTDOWN_PRIORITY) server