Skip to content

Conversation

@fcfangcc
Copy link
Contributor

@github-actions github-actions bot added the C-client Containerd client label Apr 24, 2024

// Taken from https://github.com/hyperium/tonic/commit/b90c3408001f762a32409f7e2cf688ebae39d89e#diff-f27114adeedf7b42e8656c8a86205685a54bae7a7929b895ab62516bdf9ff252R15
let channel = Endpoint::try_from("https://[::]")
let channel = Endpoint::try_from("http://[::]")
Copy link
Contributor

Choose a reason for hiding this comment

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

are there some scenarios where we would want https?

Copy link
Member

Choose a reason for hiding this comment

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

tonic::transport::Error(Transport, hyper::Error(Connect, HttpsUriWithoutTlsSupport(())))

Possibly we could enable a missing feature in Tonic instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The https://[::] is disabled here, you can any str replace https.(Except https and tls feature enable)

Connect will replace connect_with_connector function with xx.sock .

Style of writing because Tonic channel only build with Endpoint

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I think I see now, the comment right above links to a sample that states:

// We will ignore this uri because uds do not use it
// if your connector does use the uri it will be provided
// as the request to the `MakeConnection`.

Endpoint parses as URI but the domain socket isn't a uri so we move on and connect to the with our client. The uri that was initially passed is ignored in statement below tower::service_fn(move |_<this is the uri>| {

When the value is https and tls feature is enabled (as it is) it executes this code on that temp value: https://github.com/hyperium/tonic/blob/eeb3268f71ae5d1107c937392389db63d8f721fb/tonic/src/transport/service/connector.rs#L80-L91

We could essentially change this string to anything we want that parses as an "endpoint" (Uri) like unix://unused since it isn't used.

We could also be more explicit and append file::// to the path like:

let channel = Endpoint::try_from("file://var/run/containerd/containerd.sock")
        .unwrap()
        .connect_with_connector(tower::service_fn(move |uri: tonic::transport::Uri| {
            let p = uri.path().to_owned();
            UnixStream::connect(p)
        }))
        .await?;

Copy link
Member

Choose a reason for hiding this comment

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

oh, sorry, now I get it too :)
I think it deserves a comment.

@jsturtevant
Copy link
Contributor

LGTM, @fcfangcc could you add a comment explaining what is happening?

@fcfangcc
Copy link
Contributor Author

@jsturtevant You mean to add a comment explaining in the source code?

@jsturtevant
Copy link
Contributor

Yes, essentially describing a summary of #264 (comment). We had to dive in and dig around to figure out what was going on. It would be nice to leave a quick explanation for the next person to point out what seems like a strange set up (setting up with http/https but actually ignoring that value all together and using our own logic to connect).

@mxpv mxpv added this pull request to the merge queue May 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 7, 2024
@mxpv mxpv added this pull request to the merge queue May 7, 2024
Merged via the queue into containerd:main with commit e455835 May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-client Containerd client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

containerd-client connect failed when toinc with tls feature

3 participants