Skip to content

Commit 12a43cc

Browse files
committed
feat(BOUN-706): dont require full check cycle for new nodes in the control-plane
1 parent 94553a8 commit 12a43cc

File tree

1 file changed

+24
-10
lines changed
  • rs/boundary_node/control_plane/src

1 file changed

+24
-10
lines changed

rs/boundary_node/control_plane/src/check.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,36 @@ impl<R: Retrieve + Send + Sync, C: Check, P: Persist> CheckPersistRunner<R, C, P
133133
.await
134134
.context("failed to check node");
135135

136-
// Update the `checks` entry
137-
let mut entry = checks
138-
.entry((subnet_id.to_string(), node.node_id.clone()))
139-
.or_default();
140-
entry.last_updated = current_run_id;
141-
entry.ok_count = if check_result.is_err() {
142-
0
143-
} else {
144-
min_ok_count.min(entry.ok_count + 1)
136+
let k = (
137+
subnet_id.to_string(), // subnet
138+
node.node_id.clone(), // node
139+
);
140+
141+
let ok_count = match (checks.get(&k), &check_result) {
142+
// If check failed, reset OK count to 0
143+
(_, Err(_)) => 0,
144+
145+
// If check succeeded, but is also the first check, set OK count to max-value
146+
(None, Ok(_)) => min_ok_count,
147+
148+
// Otherwise, increment OK count
149+
(Some(entry), Ok(_)) => min_ok_count.min(entry.ok_count + 1),
145150
};
146151

152+
// Update the `checks` entry
153+
checks.insert(
154+
k,
155+
CheckState {
156+
ok_count,
157+
last_updated: current_run_id,
158+
},
159+
);
160+
147161
// Return the node
148162
check_result.map(|check_result| NodeCheck {
149163
node,
150164
height: check_result.height,
151-
ok_count: entry.ok_count,
165+
ok_count,
152166
})
153167
}
154168

0 commit comments

Comments
 (0)