-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add config for the header use by the general ingress #638
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fd3cb96
Add config for the header use by the general ingress
6d1a763
always add middleware but don't always add the header
5079a2c
capitalize the header
8d97cf0
use lower case
1cb2425
address some of the feedback
091d9c7
add unit test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,11 @@ import ( | |
|
||
"github.com/apache/thrift/lib/go/thrift" | ||
|
||
"github.com/reddit/baseplate.go" | ||
"github.com/reddit/baseplate.go/ecinterface" | ||
baseplatethrift "github.com/reddit/baseplate.go/internal/gen-go/reddit/baseplate" | ||
"github.com/reddit/baseplate.go/thriftbp" | ||
"github.com/reddit/baseplate.go/thriftbp/thrifttest" | ||
) | ||
|
||
const ( | ||
|
@@ -190,6 +193,49 @@ func TestBehaviorWithNetworkIssues(t *testing.T) { | |
} | ||
} | ||
|
||
type thriftHostnameHandler struct { | ||
server baseplate.Server | ||
} | ||
|
||
func (thriftHostnameHandler) IsHealthy(ctx context.Context, _ *baseplatethrift.IsHealthyRequest) (r bool, err error) { | ||
value, ok := thrift.GetHeader(ctx, thriftbp.ThriftHostnameHeader) | ||
if !ok { | ||
return false, errors.New("did not find the thrift header") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would slightly prefer to add |
||
} | ||
if value != "my-thrift-header" { | ||
return false, errors.New("unexpected value for the thrift header") | ||
} | ||
return true, nil | ||
} | ||
|
||
func TestThriftHostnameHeader(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
store := newSecretsStore(t) | ||
defer store.Close() | ||
|
||
handler := thriftHostnameHandler{} | ||
server, err := thrifttest.NewBaseplateServer(thrifttest.ServerConfig{ | ||
Processor: baseplatethrift.NewBaseplateServiceV2Processor(&handler), | ||
SecretStore: store, | ||
ClientConfig: thriftbp.ClientPoolConfig{ | ||
ThriftHostnameHeader: "my-thrift-header", | ||
}, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
handler.server = server | ||
server.Start(ctx) | ||
|
||
client := baseplatethrift.NewBaseplateServiceV2Client(server.ClientPool.TClient()) | ||
_, err = client.IsHealthy(ctx, &baseplatethrift.IsHealthyRequest{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestInitialConnectionsFallback(t *testing.T) { | ||
ln, err := net.Listen("tcp", addr) | ||
if err != nil { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intentionally lower-case?
for THeaders we use Camel-Case (see https://github.com/reddit/baseplate.go/blob/master/transport/headers.go), it will be better to keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's the value the ingress expects sadly.
@davinci26 can comment on whether this can be changed or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So according to the HTTP RFC header casing doesnt matter. @fishy does the same apply for
thrift
?In any case
envoy
will lower case the headers when parsing the thrift payload so it doesn't care but it would be nice if we took a dependency on a thrift spec definition rather than an envoy implementation detail.https://github.com/envoyproxy/envoy/blob/12210e53db6cea79b58ee027f047faa356e1e392/source/extensions/filters/network/thrift_proxy/header_transport_impl.cc#L163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this is not http header, it's thrift header.
envoy lower case all headers was a bug and fixed in latest version of envoy: envoyproxy/envoy#20595, envoyproxy/envoy@53867ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I am reading the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then in that case I think we should maintain the original casing so we follow the
thrift
protocol rather than the envoy implementation detailThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even if this breaks the code pattern here. This is a header defined externally to baseplate.go so it should be fine to have different casing