Skip to content

Commit 164df8d

Browse files
committed
[KYUUBI #6866][FOLLOWUP] Prevent register gauge conflicts if both thrift binary SSL and thrift http SSL enabled
### Why are the changes needed? Followup for #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 ea35676 [Wang, Fei] prevent conflicts 982f175 [Wang, Fei] conflicts Authored-by: Wang, Fei <[email protected]> Signed-off-by: Wang, Fei <[email protected]>
1 parent 8742334 commit 164df8d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class MetricsSystem extends CompositeService("MetricsSystem") {
5858
meter.mark(value)
5959
}
6060

61+
def getGauge[T](name: String): Option[Gauge[T]] = {
62+
Option(registry.gauge(name))
63+
}
64+
6165
def registerGauge[T](name: String, value: => T, default: T): Unit = {
6266
registry.register(
6367
MetricRegistry.name(name),

kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ object SSLUtils extends Logging {
5656
keyStorePath.get,
5757
keyStorePassword.get,
5858
keyStoreType).foreach { expiration =>
59-
info(s"Thrift SSL Serve KeyStore ${keyStorePath.get} will expire at:" +
59+
info(s"Thrift SSL Server KeyStore ${keyStorePath.get} will expire at:" +
6060
s" ${Utils.getDateFromTimestamp(expiration)}")
6161
MetricsSystem.tracing { ms =>
62-
ms.registerGauge(
63-
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
64-
expiration - System.currentTimeMillis(),
65-
0L)
62+
if (ms.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) {
63+
ms.registerGauge(
64+
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
65+
expiration - System.currentTimeMillis(),
66+
0L)
67+
}
6668
}
6769
}
6870
}

0 commit comments

Comments
 (0)