-
Notifications
You must be signed in to change notification settings - Fork 318
improvements to initial member handling #10176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
bd9bab8
93d1731
13c145a
4d21841
ebabca7
c97dfdb
55292c8
5a04c24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,7 +33,8 @@ use std::{collections::HashSet, | |||||||||||||||||||||
| iter::FromIterator, | ||||||||||||||||||||||
| net::{SocketAddr, | ||||||||||||||||||||||
| UdpSocket}, | ||||||||||||||||||||||
| sync::mpsc, | ||||||||||||||||||||||
| sync::{atomic::Ordering, | ||||||||||||||||||||||
| mpsc}, | ||||||||||||||||||||||
| thread, | ||||||||||||||||||||||
| time::{Duration, | ||||||||||||||||||||||
| Instant}}; | ||||||||||||||||||||||
|
|
@@ -94,27 +95,63 @@ pub fn spawn_thread(name: String, | |||||||||||||||||||||
| /// before starting the next probe. | ||||||||||||||||||||||
| fn run_loop(server: &Server, socket: &UdpSocket, rx_inbound: &AckReceiver, timing: &Timing) -> ! { | ||||||||||||||||||||||
| let mut have_members = false; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| loop { | ||||||||||||||||||||||
| liveliness_checker::mark_thread_alive().and_divergent(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if !have_members { | ||||||||||||||||||||||
| // Check if new initial members have been added via peer watch file | ||||||||||||||||||||||
| let new_initial_members_added = server.new_initial_members.load(Ordering::Acquire); | ||||||||||||||||||||||
| if new_initial_members_added { | ||||||||||||||||||||||
| // Reset the flag and force re-evaluation of initial member pinging | ||||||||||||||||||||||
| server.new_initial_members.store(false, Ordering::Relaxed); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| server.new_initial_members.store(false, Ordering::Relaxed); | |
| server.new_initial_members.store(false, Ordering::Release); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resetting new_initial_members with a separate load() then store(false, ...) can lose signals: if another thread sets the flag to true between the load and the store, this store will overwrite it back to false, and the outbound loop may miss the update. Use an atomic read-modify-write (e.g., swap(false, Ordering::AcqRel) or compare_exchange loop) to clear the flag without dropping concurrent updates, and use a non-Relaxed ordering consistent with the producer’s Release store.
| let new_initial_members_added = server.new_initial_members.load(Ordering::Acquire); | |
| if new_initial_members_added { | |
| // Reset the flag and force re-evaluation of initial member pinging | |
| server.new_initial_members.store(false, Ordering::Relaxed); | |
| let new_initial_members_added = | |
| server.new_initial_members.swap(false, Ordering::AcqRel); | |
| if new_initial_members_added { | |
| // Reset the flag and force re-evaluation of initial member pinging |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,9 +16,6 @@ services: | |||||||||
| - run | ||||||||||
| - --listen-ctl=0.0.0.0:9632 | ||||||||||
| - --peer-watch-file=/hab/PEERS | ||||||||||
|
||||||||||
| - --peer-watch-file=/hab/PEERS | |
| - --peer-watch-file=/hab/PEERS | |
| volumes: | |
| - ./testcases/peer_watcher/PEERS:/hab/PEERS |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The peer watch file path is configured on the bastion supervisor (--peer-watch-file=/hab/PEERS), but the bind mount for ./testcases/peer_watcher/PEERS is now only on the tester service. This means edits made by the test may not be visible inside the bastion container, so the supervisor won’t detect changes. Fix by mounting the same host file into bastion as well (or use a shared named volume mounted into both containers at /hab/PEERS).
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The peer watch file path is configured on the bastion supervisor (--peer-watch-file=/hab/PEERS), but the bind mount for ./testcases/peer_watcher/PEERS is now only on the tester service. This means edits made by the test may not be visible inside the bastion container, so the supervisor won’t detect changes. Fix by mounting the same host file into bastion as well (or use a shared named volume mounted into both containers at /hab/PEERS).
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,13 @@ Describe "Finding peers from watch file" { | |||||||||
| $timeoutScript = { Write-Error "Timed out waiting 45 seconds for all members to reach bastion" } | ||||||||||
| Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout 45 | ||||||||||
| $json = (Invoke-WebRequest "http://bastion.habitat.dev:9631/census" | ConvertFrom-Json) | ||||||||||
| $json.last_membership_counter | Should -Be 2 | ||||||||||
| } | ||||||||||
|
|
||||||||||
| It "adds beta to the peer watch file and finds it as a peer" { | ||||||||||
| Add-Content -Path "/hab/PEERS" -Value "beta.habitat.dev" | ||||||||||
| Start-Sleep -Seconds 5 # give butterfly some time to detect the change and update the census | ||||||||||
|
||||||||||
| Start-Sleep -Seconds 5 # give butterfly some time to detect the change and update the census | |
| $testScript = { (Invoke-WebRequest "http://bastion.habitat.dev:9631/census" | ConvertFrom-Json).last_membership_counter -eq 3 } | |
| $timeoutScript = { Write-Error "Timed out waiting 45 seconds for beta to be detected and the census to reach last_membership_counter 3" } | |
| Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout 45 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import for
Ordering. Theatomic::Orderingtype is used here but not imported in the visible portion of this file. Ensureuse std::sync::atomic::Ordering;is added to the imports at the top of the file.