Skip to content

Commit

Permalink
fix(node): warn if "(deleted)" exists in exe name during restart
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Jan 24, 2024
1 parent 903092b commit c0bd504
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ jobs:
SN_LOG: "all"
timeout-minutes: 30

- name: Check current files
run: ls -la
- name: Check safenode file
run: ls /home/runner/work/safe_network/safe_network/target/release

- name: Check there was no restart issues
run: |
if rg 'Failed to execute hard-restart command' $NODE_DATA_PATH; then
echo "Restart issues detected"
exit 1
else
echo "No restart issues detected"
fi
- name: Verify the routing tables of the nodes
run: cargo test --release -p sn_node --test verify_routing_table -- --nocapture
env:
Expand Down
12 changes: 9 additions & 3 deletions sn_networking/src/record_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,15 @@ mod tests {

// Execute for 50 iterations, which allows the test can be executed in normal CI runs.
if iteration == 50 {
assert_eq!(0, empty_earned_nodes);
assert!((max_store_cost / min_store_cost) < 60);
assert!((max_earned / min_earned) < 800);
assert_eq!(0, empty_earned_nodes, "every node has earnt _something_");
assert!(
(max_store_cost / min_store_cost) < 60,
"store cost is balanced"
);
assert!(
(max_earned / min_earned) < 800,
"earning distribution is well balanced"
);
break;
}
}
Expand Down
18 changes: 18 additions & 0 deletions sn_node/src/bin/safenode/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,24 @@ fn start_new_node_process() {
let args: Vec<String> = env::args().collect();

info!("Original args are: {args:?}");
info!("Current exe is: {current_exe:?}");

// Convert current exe path to string, log an error and return if it fails
let current_exe = match current_exe.to_str() {
Some(s) => {
// remove "(deleted)" string from current exe path
if s.contains(" (deleted)") {
warn!("The current executable path contains ' (deleted)', which may lead to unexpected behavior. This has been removed from the exe location string");
s.replace(" (deleted)", "")
} else {
s.to_string()
}
}
None => {
error!("Failed to convert current executable path to string");
return;
}
};

// Create a new Command instance to run the current executable
let mut cmd = Command::new(current_exe);
Expand Down

0 comments on commit c0bd504

Please sign in to comment.