Skip to content

Commit

Permalink
bugfix: faild to symlink console socket into container_dir.
Browse files Browse the repository at this point in the history
The issue of the container failing to start through Youki due
due to the improper initialization of socket_path has been resolved.

Signed-off-by: taohong <[email protected]>
  • Loading branch information
taoohong committed Sep 30, 2024
1 parent 29d5019 commit 4f68e92
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions vmm/task/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,20 @@ impl KuasarFactory {
}
Err(e) => debug!("get mount type failed {}", e),
};
let mut socket_path = PathBuf::new();
let (socket, pio) = if stdio.terminal {

let (socket, pio, socket_path) = if stdio.terminal {
let s = ConsoleSocket::new().await?;
socket_path = s.path.to_owned();
(Some(s), None)
let path = s.path.to_owned();
(Some(s), None, Some(path))
} else {
let pio = create_io(&id, opts.io_uid, opts.io_gid, stdio)?;
(None, Some(pio))
};
(None, Some(pio), None)
};

let resp = ContainerBuilder::new(id.to_string(), SyscallType::default())
.with_pid_file(Some(pid_path.clone()))
.map_err(other_error!(e, "failed to set youki create pid file"))?
.with_console_socket(Some(socket_path))
.with_console_socket(socket_path)
.with_root_path(PathBuf::from(YOUKI_DIR))
.map_err(other_error!(e, "failed to set youki create root path"))?
.as_init(bundle)
Expand Down Expand Up @@ -431,15 +432,14 @@ impl KuasarInitLifecycle {
impl ProcessLifecycle<ExecProcess> for KuasarExecLifecycle {
async fn start(&self, p: &mut ExecProcess) -> containerd_shim::Result<()> {
rescan_pci_bus().await?;
let pid_path = Path::new(self.bundle.as_str()).join(format!("{}.pid", &p.id));
let mut socket_path = PathBuf::new();
let (socket, pio) = if p.stdio.terminal {
let pid_path = Path::new(self.bundle.as_str()).join(format!("{}.pid", &p.id));
let (socket, pio, socket_path) = if p.stdio.terminal {
let s = ConsoleSocket::new().await?;
socket_path = s.path.to_owned();
(Some(s), None)
let path = s.path.to_owned();
(Some(s), None, Some(path))
} else {
let pio = create_io(&p.id, self.io_uid, self.io_gid, &p.stdio)?;
(None, Some(pio))
(None, Some(pio), None)
};

let probe_path = format!("{}/{}-process.json", self.bundle, &p.id);
Expand All @@ -453,7 +453,7 @@ impl ProcessLifecycle<ExecProcess> for KuasarExecLifecycle {
let exec_result = ContainerBuilder::new(self.container_id.clone(), SyscallType::default())
.with_root_path(PathBuf::from(YOUKI_DIR))
.map_err(other_error!(e, "failed to set youki root path"))?
.with_console_socket(Some(socket_path))
.with_console_socket(socket_path)
.with_pid_file(Some(pid_path.clone()))
.map_err(other_error!(e, "failed to set process pid file"))?
.as_tenant()
Expand Down

0 comments on commit 4f68e92

Please sign in to comment.