[next-0.10] cluster node status metrics: report nodes of all active layout versions
Some checks failed
ci/woodpecker/pr/debug Pipeline was successful
ci/woodpecker/push/debug Pipeline was successful
ci/woodpecker/deployment/release/2 Pipeline failed
ci/woodpecker/deployment/release/1 Pipeline failed
ci/woodpecker/deployment/debug Pipeline was successful
ci/woodpecker/deployment/release/4 Pipeline failed
ci/woodpecker/deployment/release/3 Pipeline failed
ci/woodpecker/deployment/publish unknown status

This commit is contained in:
Alex 2024-02-20 17:08:31 +01:00
parent 643d1aabd8
commit 75e591727d
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -216,12 +216,12 @@ impl SystemMetrics {
.u64_value_observer("cluster_layout_node_connected", move |observer| {
let layout = system.cluster_layout();
let nodes = system.get_known_nodes();
for (id, _, config) in layout.current().roles.items().iter() {
if let Some(role) = &config.0 {
let mut kv = vec![
KeyValue::new("id", format!("{:?}", id)),
KeyValue::new("role_zone", role.zone.clone()),
];
for id in layout.all_nodes().iter() {
let mut kv = vec![KeyValue::new("id", format!("{:?}", id))];
if let Some(role) =
layout.current().roles.get(id).and_then(|r| r.0.as_ref())
{
kv.push(KeyValue::new("role_zone", role.zone.clone()));
match role.capacity {
Some(cap) => {
kv.push(KeyValue::new("role_capacity", cap as i64));
@ -231,10 +231,10 @@ impl SystemMetrics {
kv.push(KeyValue::new("role_gateway", 1));
}
}
}
let value;
if let Some(node) = nodes.iter().find(|n| n.id == *id) {
value = if node.is_up { 1 } else { 0 };
// TODO: if we add address and hostname, and those change, we
// get duplicate metrics, due to bad otel aggregation :(
// Can probably be fixed when we upgrade opentelemetry
@ -243,13 +243,13 @@ impl SystemMetrics {
// "hostname",
// node.status.hostname.clone(),
// ));
value = if node.is_up { 1 } else { 0 };
} else {
value = 0;
}
observer.observe(value, &kv);
}
}
})
.with_description("Connection status for nodes in the cluster layout")
.init()
@ -260,12 +260,12 @@ impl SystemMetrics {
.u64_value_observer("cluster_layout_node_disconnected_time", move |observer| {
let layout = system.cluster_layout();
let nodes = system.get_known_nodes();
for (id, _, config) in layout.current().roles.items().iter() {
if let Some(role) = &config.0 {
let mut kv = vec![
KeyValue::new("id", format!("{:?}", id)),
KeyValue::new("role_zone", role.zone.clone()),
];
for id in layout.all_nodes().iter() {
let mut kv = vec![KeyValue::new("id", format!("{:?}", id))];
if let Some(role) =
layout.current().roles.get(id).and_then(|r| r.0.as_ref())
{
kv.push(KeyValue::new("role_zone", role.zone.clone()));
match role.capacity {
Some(cap) => {
kv.push(KeyValue::new("role_capacity", cap as i64));
@ -275,6 +275,7 @@ impl SystemMetrics {
kv.push(KeyValue::new("role_gateway", 1));
}
}
}
if let Some(node) = nodes.iter().find(|n| n.id == *id) {
// TODO: see comment above
@ -290,7 +291,6 @@ impl SystemMetrics {
}
}
}
}
})
.with_description(
"Time (in seconds) since last connection to nodes in the cluster layout",