Skip to content

Relax authority strictness for interoperability with other (existing) clients #243

Open
@gila

Description

@gila

Feature Request

During the implementation of a CSI driver, and working with existing gRPC clients that require a UDS socket, all requests are failed with reason=PROTOCOL_ERROR.

Here is an example when testing the "Identity" service of such a driver:

$ ./csc -e /var/tmp/csi.sock identity plugin-info                                                          [±h2 ●●]
WARN[0000] debug mode enabled
DEBU[0000] assigned the root context
DEBU[0000] enabled request ID injector
DEBU[0000] enabled request logging
INFO[0000] /csi.v1.Identity/GetPluginInfo: REQ 0001: XXX_NoUnkeyedLiteral={}, XXX_sizecache=0
DEBU[0000] parsed endpoint info                          addr=/var/tmp/csi.sock proto=unix timeout=1m0s
stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

From the server-side of things with RUST_LOG set to trace we can see:

DEBUG h2::server] malformed headers: malformed authority (b"/var/tmp/csi.sock"): invalid uri character
[2020-01-18T14:26:10Z TRACE h2::proto::streams::send] send_reset(..., reason=PROTOCOL_ERROR, stream=StreamId(1), ..., is_reset=false; is_closed=false; pending_send.is_empty=true; state=State { inner: Open { local: AwaitingHeaders, remote: Streaming } }

So the problem is pretty clear straight from here. We are sending an invalid (in context from HTTP for sure) an invalid authority and we error out at https://github.com/hyperium/http/blob/master/src/uri/authority.rs#L96

So in principle, the system works as designed. However according to RFC-3986:

For example, the "file" URI  scheme is defined so that no authority, an empty host, and
"localhost" all mean the end-user's machine, whereas the "http"   scheme considers a missing 
authority or empty host invalid.

Unfortunately, it seems to be the case that google, instead of using the "file://" scheme has invented its own scheme "unix://" there is a known issue for this filed here: grpc/grpc-go#2628

Regardless of the scheme used here it still would not work as the only scheme considered (and it looks to be implicit) is the http scheme, which makes sense as h2 states to be an HTTP server.

Currently, the way to we work around this is to patch h2 but this is suboptimal, and I can imagine other users might run into this problem as well. Although the problem itself simple, finding the right solution is not as the h2 crate and the HTTP crate are written to deal with HTTP.

Motivation

Would like to use tonic without the need to patch h2 or http

Proposal

Find an away to change/register handlers for schemes other than the http:// scheme or at least support unix:// and/or file:// ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions