Skip to content

Commit 5a23838

Browse files
committed
chore: replace jmx exporter with built in Prometheus support
1 parent 0bbc3a9 commit 5a23838

3 files changed

Lines changed: 50 additions & 17 deletions

File tree

rust/operator-binary/src/config/jvm.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use stackable_operator::{
66

77
use crate::crd::{
88
JVM_SECURITY_PROPERTIES_FILE, LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE, LoggingFramework,
9-
METRICS_PORT, STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
9+
STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
1010
v1alpha1::{ZookeeperCluster, ZookeeperConfig, ZookeeperConfigFragment},
1111
};
1212

@@ -36,9 +36,6 @@ fn construct_jvm_args(
3636

3737
let jvm_args = vec![
3838
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
39-
format!(
40-
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/server.yaml"
41-
),
4239
match logging_framework {
4340
LoggingFramework::LOG4J => {
4441
format!("-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}")
@@ -123,7 +120,6 @@ mod tests {
123120
assert_eq!(
124121
non_heap_jvm_args,
125122
"-Djava.security.properties=/stackable/config/security.properties \
126-
-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar=9505:/stackable/jmx/server.yaml \
127123
-Dlogback.configurationFile=/stackable/log_config/logback.xml"
128124
);
129125
assert_eq!(zk_server_heap_env, "409");
@@ -168,7 +164,6 @@ mod tests {
168164
assert_eq!(
169165
non_heap_jvm_args,
170166
"-Djava.security.properties=/stackable/config/security.properties \
171-
-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar=9505:/stackable/jmx/server.yaml \
172167
-Dlogback.configurationFile=/stackable/log_config/logback.xml \
173168
-Dhttps.proxyHost=proxy.my.corp \
174169
-Djava.net.preferIPv4Stack=true \

rust/operator-binary/src/crd/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ pub const OPERATOR_NAME: &str = "zookeeper.stackable.tech";
4747
pub const ZOOKEEPER_PROPERTIES_FILE: &str = "zoo.cfg";
4848
pub const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
4949

50-
pub const METRICS_PORT: u16 = 9505;
50+
pub const METRICS_PROVIDER_CLASS_NAME: &str =
51+
"org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider";
52+
pub const METRICS_PROVIDER_HTTP_PORT: u16 = 9505;
5153

5254
pub const STACKABLE_DATA_DIR: &str = "/stackable/data";
5355
pub const STACKABLE_CONFIG_DIR: &str = "/stackable/config";
@@ -371,6 +373,8 @@ impl v1alpha1::ZookeeperConfig {
371373
pub const DATA_DIR: &'static str = "dataDir";
372374
const DEFAULT_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
373375
pub const INIT_LIMIT: &'static str = "initLimit";
376+
const METRICS_PROVIDER_CLASS_NAME: &'static str = "metricsProvider.className";
377+
const METRICS_PROVIDER_HTTP_PORT: &'static str = "metricsProvider.httpPort";
374378
pub const MYID_OFFSET: &'static str = "MYID_OFFSET";
375379
pub const SYNC_LIMIT: &'static str = "syncLimit";
376380
pub const TICK_TIME: &'static str = "tickTime";
@@ -468,6 +472,14 @@ impl Configuration for v1alpha1::ZookeeperConfigFragment {
468472
v1alpha1::ZookeeperConfig::DATA_DIR.to_string(),
469473
Some(STACKABLE_DATA_DIR.to_string()),
470474
);
475+
result.insert(
476+
v1alpha1::ZookeeperConfig::METRICS_PROVIDER_CLASS_NAME.to_string(),
477+
Some(METRICS_PROVIDER_CLASS_NAME.to_string()),
478+
);
479+
result.insert(
480+
v1alpha1::ZookeeperConfig::METRICS_PROVIDER_HTTP_PORT.to_string(),
481+
Some(METRICS_PROVIDER_HTTP_PORT.to_string()),
482+
);
471483
}
472484

473485
Ok(result)

tests/templates/kuttl/smoke/test_zookeeper.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import requests
44
import time
55
import sys
6+
67
sys.tracebacklimit = 0
78

89

@@ -37,18 +38,29 @@ def check_ruok(hosts):
3738
url = host + ":8080/commands/" + cmd_ruok
3839
response = try_get(url).json()
3940

40-
if "command" in response and response["command"] == cmd_ruok \
41-
and "error" in response and response["error"] is None:
41+
if (
42+
"command" in response
43+
and response["command"] == cmd_ruok
44+
and "error" in response
45+
and response["error"] is None
46+
):
4247
continue
4348
else:
44-
print("Error[" + cmd_ruok + "] for [" + url + "]: received " + str(
45-
response) + " - expected {'command': 'ruok', 'error': None} ")
49+
print(
50+
"Error["
51+
+ cmd_ruok
52+
+ "] for ["
53+
+ url
54+
+ "]: received "
55+
+ str(response)
56+
+ " - expected {'command': 'ruok', 'error': None} "
57+
)
4658
exit(-1)
4759

4860

4961
def check_monitoring(hosts):
5062
for host in hosts:
51-
url = host + ":9505"
63+
url = host + ":9505/metrics"
5264
response = try_get(url)
5365

5466
if response.ok:
@@ -58,15 +70,29 @@ def check_monitoring(hosts):
5870
exit(-1)
5971

6072

61-
if __name__ == '__main__':
73+
if __name__ == "__main__":
6274
all_args = argparse.ArgumentParser(description="Test ZooKeeper.")
63-
all_args.add_argument("-n", "--namespace", help="The namespace to run in", required=True)
75+
all_args.add_argument(
76+
"-n", "--namespace", help="The namespace to run in", required=True
77+
)
6478
args = vars(all_args.parse_args())
6579
namespace = args["namespace"]
6680

67-
host_primary_0 = "http://test-zk-server-primary-0.test-zk-server-primary." + namespace + ".svc.cluster.local"
68-
host_primary_1 = "http://test-zk-server-primary-1.test-zk-server-primary." + namespace + ".svc.cluster.local"
69-
host_secondary = "http://test-zk-server-secondary-0.test-zk-server-secondary." + namespace + ".svc.cluster.local"
81+
host_primary_0 = (
82+
"http://test-zk-server-primary-0.test-zk-server-primary."
83+
+ namespace
84+
+ ".svc.cluster.local"
85+
)
86+
host_primary_1 = (
87+
"http://test-zk-server-primary-1.test-zk-server-primary."
88+
+ namespace
89+
+ ".svc.cluster.local"
90+
)
91+
host_secondary = (
92+
"http://test-zk-server-secondary-0.test-zk-server-secondary."
93+
+ namespace
94+
+ ".svc.cluster.local"
95+
)
7096

7197
hosts = [host_primary_0, host_primary_1, host_secondary]
7298

0 commit comments

Comments
 (0)