Skip to content

No need to write address twice #331

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions crates/shim/src/asynchronous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::{
asynchronous::{monitor::monitor_notify_by_pid, publisher::RemotePublisher},
error::{Error, Result},
logger, parse_sockaddr, reap, socket_address,
util::{asyncify, read_file_to_str, write_str_to_file},
util::{asyncify, read_file_to_str},
Config, Flags, StartOpts, SOCKET_FD, TTRPC_ADDRESS,
};

Expand Down Expand Up @@ -260,8 +260,7 @@ pub async fn spawn(opts: StartOpts, grouping: &str, vars: Vec<(&str, &str)>) ->
return Err(e);
};
}
if let Ok(()) = wait_socket_working(&address, 5, 200).await {
write_str_to_file("address", &address).await?;
if wait_socket_working(&address, 5, 200).await.is_ok() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the first write?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while the service's start_shim call spawn , if the spawn return ok ,will write address again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jokemanfire this isn't the same as writing it to the std_out. This is writing it to the oci bundle path as a file. I believe this is required so that if containerd restarts it knows how to reconnect to the shim:

https://github.com/containerd/containerd/blob/29ecab63c8c200f286a2439ea6bdddfa3d4fcaa8/cmd/containerd-shim-runc-v2/task/service.go#L102-L106

Copy link
Contributor Author

@jokemanfire jokemanfire Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsturtevant , I know the socket address will be written but I feel confuse about this rshim

        let vars: Vec<(&str, &str)> = vec![("THP_DISABLED", thp_disabled.as_str())];

        let address = spawn(opts, &grouping, vars).await?;
        write_str_to_file("address", &address).await?;

also write address to address's file again .
but the func spawn return type is ok.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing two times "false" written to my container logs?

return Ok(address);
}
remove_socket(&address).await?;
Expand Down
Loading