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
xds: implement fault injection HTTP filter (A33) #4236
Conversation
|
||
func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.FilterConfig, error) { | ||
// Parsing is the same for the override config. | ||
return builder{}.ParseFilterConfig(override) |
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.
Name the receiver and use it, instead of create a new one.
Or just make a local function, and call it in both Parse()
methods.
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.
Done (latter).
md, _ := metadata.FromOutgoingContext(ctx) | ||
if v := md[headerDelayDuration]; v != nil { | ||
if ms, ok := parseIntFromMD(v); ok { | ||
delay = time.Duration(time.Duration(ms) * time.Millisecond) |
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.
The outer time.Duration
conversion is redundant.
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.
Done
} else { | ||
return nil | ||
} | ||
} else { |
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.
How about
v := md[headerDelayDuration]
if v == nil {
return nil
}
ms, ok := parseIntFromMD(v)
if! ok {
return nil
}
delay = time.Duration(time.Duration(ms) * time.Millisecond)
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.
Good call, done. All the else
s can be confusing.
code, okCode = sanitizeGRPCCode(codes.Code(errType.GrpcStatus)), true | ||
case *fpb.FaultAbort_HeaderAbort_: | ||
md, _ := metadata.FromOutgoingContext(ctx) | ||
if v := md[headerAbortHTTPStatus]; v != nil { |
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 it by design that http status has higher priority than gRPC status?
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.
If both x-envoy-fault-abort-request and x-envoy-fault-abort-grpc-request headers are set then x-envoy-fault-abort-grpc-request header will be ignored and fault response http status code will be set to x-envoy-fault-abort-request header value.
} | ||
|
||
// For overriding in tests | ||
var intn = grpcrand.Intn |
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.
Rename this to randIntn
? I at first thought this is a type conversion.
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.
Done
|
||
func (*okStream) Header() (metadata.MD, error) { return nil, nil } | ||
func (*okStream) Trailer() metadata.MD { return nil } | ||
func (*okStream) CloseSend() error { return nil } |
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.
CloseSend should also return io.EOF
, it's a special send
.
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.
I don't think that's right. We never return an error from CloseSend:
Lines 831 to 834 in 930c791
// Always return nil; io.EOF is the only error that might make sense | |
// instead, but there is no need to signal the client to call RecvMsg | |
// as the only use left for the stream after CloseSend is to call | |
// RecvMsg. This also matches historical behavior. |
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.
There was a test failure that was/is concerning, but I've re-run locally for hundreds of runs without encountering them. Also the failing test run on GA included a non-FI test failure that I've never seen before, so maybe solar flares are to blame?
|
||
func (builder) ParseFilterConfigOverride(override proto.Message) (httpfilter.FilterConfig, error) { | ||
// Parsing is the same for the override config. | ||
return builder{}.ParseFilterConfig(override) |
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.
Done (latter).
} | ||
|
||
// For overriding in tests | ||
var intn = grpcrand.Intn |
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.
Done
md, _ := metadata.FromOutgoingContext(ctx) | ||
if v := md[headerDelayDuration]; v != nil { | ||
if ms, ok := parseIntFromMD(v); ok { | ||
delay = time.Duration(time.Duration(ms) * time.Millisecond) |
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.
Done
} else { | ||
return nil | ||
} | ||
} else { |
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.
Good call, done. All the else
s can be confusing.
code, okCode = sanitizeGRPCCode(codes.Code(errType.GrpcStatus)), true | ||
case *fpb.FaultAbort_HeaderAbort_: | ||
md, _ := metadata.FromOutgoingContext(ctx) | ||
if v := md[headerAbortHTTPStatus]; v != nil { |
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.
If both x-envoy-fault-abort-request and x-envoy-fault-abort-grpc-request headers are set then x-envoy-fault-abort-grpc-request header will be ignored and fault response http status code will be set to x-envoy-fault-abort-request header value.
|
||
func (*okStream) Header() (metadata.MD, error) { return nil, nil } | ||
func (*okStream) Trailer() metadata.MD { return nil } | ||
func (*okStream) CloseSend() error { return nil } |
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.
I don't think that's right. We never return an error from CloseSend:
Lines 831 to 834 in 930c791
// Always return nil; io.EOF is the only error that might make sense | |
// instead, but there is no need to signal the client to call RecvMsg | |
// as the only use left for the stream after CloseSend is to call | |
// RecvMsg. This also matches historical behavior. |
Can you rebase this onto master? To fix the conflicts, and also then this PR will show only the new diffs. |
Done! |
ccecbd2
to
37dc149
Compare
@@ -0,0 +1,646 @@ | |||
// +build !386 |
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.
Why is this?
73beb7f
to
48590fd
Compare
48590fd
to
559b7aa
Compare
also contains all of #4235