This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch branch-1.10
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.10 by this push:
new cc6702da6a [KYUUBI #6866][FOLLOWUP] Prevent register gauge conflicts
if both thrift binary SSL and thrift http SSL enabled
cc6702da6a is described below
commit cc6702da6ae8e9ceacba2bcdd2e2e29b8327782b
Author: Wang, Fei <[email protected]>
AuthorDate: Thu Dec 26 18:22:48 2024 -0800
[KYUUBI #6866][FOLLOWUP] Prevent register gauge conflicts if both thrift
binary SSL and thrift http SSL enabled
### Why are the changes needed?
Followup for https://github.com/apache/kyuubi/pull/6866
It would throw exception if both thrift binary SSL and thrift http SSL
enabled
### How was this patch tested?
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #6872 from turboFei/duplicate_gauge.
Closes #6866
ea356766e [Wang, Fei] prevent conflicts
982f175fd [Wang, Fei] conflicts
Authored-by: Wang, Fei <[email protected]>
Signed-off-by: Wang, Fei <[email protected]>
(cherry picked from commit 164df8d4660ac5ed73db0b5ea74b99c391f7dbf8)
Signed-off-by: Wang, Fei <[email protected]>
---
.../main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala | 4 ++++
.../src/main/scala/org/apache/kyuubi/util/SSLUtils.scala | 12 +++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git
a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala
b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala
index 26344ca56a..3db6daba4b 100644
---
a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala
+++
b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala
@@ -58,6 +58,10 @@ class MetricsSystem extends
CompositeService("MetricsSystem") {
meter.mark(value)
}
+ def getGauge[T](name: String): Option[Gauge[T]] = {
+ Option(registry.gauge(name))
+ }
+
def registerGauge[T](name: String, value: => T, default: T): Unit = {
registry.register(
MetricRegistry.name(name),
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala
b/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala
index f73f87b904..c0765b9a40 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala
@@ -56,13 +56,15 @@ object SSLUtils extends Logging {
keyStorePath.get,
keyStorePassword.get,
keyStoreType).foreach { expiration =>
- info(s"Thrift SSL Serve KeyStore ${keyStorePath.get} will expire at:" +
+ info(s"Thrift SSL Server KeyStore ${keyStorePath.get} will expire at:"
+
s" ${Utils.getDateFromTimestamp(expiration)}")
MetricsSystem.tracing { ms =>
- ms.registerGauge(
- MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
- expiration - System.currentTimeMillis(),
- 0L)
+ if
(ms.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) {
+ ms.registerGauge(
+ MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
+ expiration - System.currentTimeMillis(),
+ 0L)
+ }
}
}
}