agent: Agent invokes OCI hooks with wrong PID

Agent sends -1 PID when invoking OCI hooks.

OCI state struct is initialized before obtaining PID, so this PR moves
`oci_state` call down, right after we get the id.

Fixes: #1458

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2021-02-24 18:06:45 -08:00 committed by Peng Tao
parent fc72d392b7
commit 3f3a2533a3

View File

@ -734,8 +734,6 @@ impl BaseContainer for LinuxContainer {
}
let linux = spec.linux.as_ref().unwrap();
let st = self.oci_state()?;
let (pfd_log, cfd_log) = unistd::pipe().context("failed to create pipe")?;
let _ = fcntl::fcntl(pfd_log, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC))
@ -865,6 +863,8 @@ impl BaseContainer for LinuxContainer {
info!(logger, "child pid: {}", p.pid);
let st = self.oci_state()?;
join_namespaces(
&logger,
&spec,