Revert "fix(kata-agent): use syslog::try_poll in drain loop to avoid …#165
Closed
zvonkok wants to merge 2 commits into
Closed
Revert "fix(kata-agent): use syslog::try_poll in drain loop to avoid …#165zvonkok wants to merge 2 commits into
zvonkok wants to merge 2 commits into
Conversation
…kata 255" This reverts commit 04b8be5.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reverts a prior kata-agent/syslog change (commit 04b8be5…) and restores the previous syslog drain behavior in the kata-agent forked child, along with related test and panic-hook visibility adjustments.
Changes:
- Switch
syslog_loop()back fromcrate::syslog::try_poll()tocrate::syslog::poll(). - Remove the regression test that asserted syslog draining wouldn’t trigger the power-off panic hook, and adjust the remaining timeout test to wrap the loop in
catch_unwind. - Make
lockdown::set_panic_hook_with()private (fn) instead ofpub(crate).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/kata_agent.rs |
Reverts syslog drain loop to poll(), updates safety comment, and modifies/removes tests tied to the prior try_poll() behavior. |
src/lockdown.rs |
Narrows visibility of the configurable panic-hook helper used for testing. |
Comment on lines
53
to
57
| let iterations = (timeout_secs as u64) * 2; // 500ms per iteration | ||
| for _ in 0..iterations { | ||
| sleep(Duration::from_millis(500)); | ||
| crate::syslog::try_poll(); | ||
| crate::syslog::poll(); | ||
| } |
Comment on lines
64
to
68
| // SAFETY: fork() is safe here because: | ||
| // 1. We are PID 1 with no other threads (single-threaded process) | ||
| // 2. Parent immediately execs kata-agent (no shared state issues) | ||
| // 3. Child only calls async-signal-safe functions (syslog::try_poll, sleep) | ||
| // 3. Child only calls async-signal-safe functions (syslog::poll, sleep) | ||
| // 4. No locks or mutexes exist that could deadlock in child |
Comment on lines
145
to
153
| fn test_syslog_loop_timeout() { | ||
| // ~1s: two 500ms iterations; try_poll() is best-effort on /dev/log. | ||
| // syslog_loop with 1 second timeout runs up to 2 iterations (500ms each). | ||
| // Two possible outcomes: | ||
| // 1. poll() works: runs full 2 iterations (~1000ms) | ||
| // 2. poll() panics: test fails due to missing /dev/log | ||
| // We catch_unwind to handle missing /dev/log gracefully in test env | ||
| let start = std::time::Instant::now(); | ||
| syslog_loop(1); | ||
| let _ = panic::catch_unwind(|| syslog_loop(1)); | ||
| let elapsed = start.elapsed(); |
Comment on lines
29
to
32
| /// Internal: panic handler with configurable shutdown (for unit tests). | ||
| /// Production uses power_off(); tests inject a no-op to avoid rebooting. | ||
| pub(crate) fn set_panic_hook_with<F: Fn() + Send + Sync + 'static>(shutdown: F) { | ||
| fn set_panic_hook_with<F: Fn() + Send + Sync + 'static>(shutdown: F) { | ||
| panic::set_hook(Box::new(move |panic_info| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…kata 255"
This reverts commit 04b8be5.