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
parent 2c42be0ca6
commit a42dc74898

View File

@ -834,8 +834,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))
@ -938,6 +936,8 @@ impl BaseContainer for LinuxContainer {
info!(logger, "child pid: {}", p.pid);
let st = self.oci_state()?;
join_namespaces(
&logger,
&spec,