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

No need to write address twice #331

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jokemanfire
Copy link
Contributor

Optimize code

Optimize code

Signed-off-by: jokemanfire <[email protected]>
@github-actions github-actions bot added the C-shim Containerd shim label Oct 28, 2024
@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-shim Containerd shim
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants