Skip to content

Revert "fix(kata-agent): use syslog::try_poll in drain loop to avoid …#165

Closed
zvonkok wants to merge 2 commits into
NVIDIA:mainfrom
zvonkok:revert-syslog-patch
Closed

Revert "fix(kata-agent): use syslog::try_poll in drain loop to avoid …#165
zvonkok wants to merge 2 commits into
NVIDIA:mainfrom
zvonkok:revert-syslog-patch

Conversation

@zvonkok

@zvonkok zvonkok commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

…kata 255"

This reverts commit 04b8be5.

Copilot AI review requested due to automatic review settings June 2, 2026 19:24
@zvonkok zvonkok added the ok-to-test Ok to test label Jun 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from crate::syslog::try_poll() to crate::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 of pub(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 thread src/kata_agent.rs
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 thread src/kata_agent.rs
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 thread src/kata_agent.rs
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 thread src/lockdown.rs
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| {
@github-actions github-actions Bot removed the ok-to-test Ok to test label Jun 2, 2026
@zvonkok zvonkok added the ok-to-test Ok to test label Jun 2, 2026
@zvonkok zvonkok closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Ok to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants