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

state: fix race condition when reading cgroup #474

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,17 @@ libcrun_get_container_state_string (const char *id, libcrun_container_status_t *

ret = libcrun_cgroup_is_container_paused (status->cgroup_path, cgroup_mode, &paused, err);
if (UNLIKELY (ret < 0))
return ret;
{
/* The cgroup might have been cleaned up by systemd by the time we try to read it, so ignore ENOENT. */
if (status->systemd_cgroup && crun_error_get_errno (err) == ENOENT)
{
crun_error_release (err);
*container_status = "stopped";
return 0;
}

return ret;
}
}

if (! *running)
Expand Down