Skip to content
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

Killing builds after timeout doesn't work reliably #110

Open
kpcyrd opened this issue Dec 10, 2021 · 1 comment
Open

Killing builds after timeout doesn't work reliably #110

kpcyrd opened this issue Dec 10, 2021 · 1 comment

Comments

@kpcyrd
Copy link
Owner

kpcyrd commented Dec 10, 2021

Especially on the debian rebuilder builds get frequently stuck during tests and the kill-after-timeout doesn't seem to work reliably.

The code that configures the timeout:

let opts = proc::Options {
timeout: Duration::from_secs(timeout),
size_limit: ctx.build.max_bytes,
kill_at_size_limit: false,
passthrough: !ctx.build.silent,
envs,
};
let (_success, log) = proc::run(bin.as_ref(), &[input_path], opts).await?;

The code that's supposed to kill the process:

pub async fn next_wakeup(&mut self, child: &mut Child) -> Result<Duration> {
// check if we need to SIGKILL due to SIGTERM timeout
if let Some(sigterm_sent) = self.sigterm_sent {
if sigterm_sent.elapsed() > Duration::from_secs(SIGKILL_DELAY) {
if let Some(pid) = child.id() {
warn!("child(pid={}) didn't terminate {}s after SIGTERM, sending SIGKILL", pid, SIGKILL_DELAY);
// child.id is going to return None after this
child.kill().await?;
}
}
}
// check if the process timed out and we need to SIGTERM
if let Some(remaining) = self.timeout.checked_sub(self.start.elapsed()) {
return Ok(remaining);
} else if self.sigterm_sent.is_none() {
// the process has timed out, sending SIGTERM
warn!("child timed out, killing...");
self.truncate(child, "TRUNCATED DUE TO TIMEOUT", true).await?;
}
// if we don't need any timeouts anymore we just return any value
Ok(Duration::from_secs(SIGKILL_DELAY))
}
}

This needs investigation.

@kpcyrd
Copy link
Owner Author

kpcyrd commented Dec 10, 2021

#111 seems to improve the situation significantly. Shoutout to @stoeckmann who helped me getting this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant