Skip to content

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.

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?

Copy link

This PR is stale because it has been open 90 days with no activity. This PR will be closed in 7 days unless new comments are made or the stale label is removed.

@github-actions github-actions bot added the Stale label Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants