Skip to content
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

Don't use wrappers for grpc metadata #2610

Merged
merged 1 commit into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/ca.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/control.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/dispatcher.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/logbroker.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/raft.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/resource.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/watch.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ca/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// forwardedTLSInfoFromContext obtains forwarded TLS CN/OU from the grpc.MD
// object in ctx.
func forwardedTLSInfoFromContext(ctx context.Context) (remoteAddr string, cn string, org string, ous []string) {
md, _ := metadata.FromContext(ctx)
md, _ := metadata.FromIncomingContext(ctx)
if len(md[remoteAddrKey]) != 0 {
remoteAddr = md[remoteAddrKey][0]
}
Expand All @@ -32,7 +32,7 @@ func forwardedTLSInfoFromContext(ctx context.Context) (remoteAddr string, cn str
}

func isForwardedRequest(ctx context.Context) bool {
md, _ := metadata.FromContext(ctx)
md, _ := metadata.FromIncomingContext(ctx)
if len(md[certForwardedKey]) != 1 {
return false
}
Expand All @@ -42,7 +42,7 @@ func isForwardedRequest(ctx context.Context) bool {
// WithMetadataForwardTLSInfo reads certificate from context and returns context where
// ForwardCert is set based on original certificate.
func WithMetadataForwardTLSInfo(ctx context.Context) (context.Context, error) {
md, ok := metadata.FromContext(ctx)
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
md = metadata.MD{}
}
Expand Down Expand Up @@ -73,5 +73,5 @@ func WithMetadataForwardTLSInfo(ctx context.Context) (context.Context, error) {
md[remoteAddrKey] = []string{peer.Addr.String()}
}

return metadata.NewContext(ctx, md), nil
return metadata.NewOutgoingContext(ctx, md), nil
}
4 changes: 2 additions & 2 deletions protobuf/plugin/raftproxy/raftproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func (g *raftProxyGen) genProxyConstructor(s *descriptor.ServiceDescriptorProto)
return ctx, status.Errorf(codes.InvalidArgument, "remote addr is not found in context")
}
addr := s.ServerTransport().RemoteAddr().String()
md, ok := metadata.FromContext(ctx)
md, ok := metadata.FromIncomingContext(ctx)
if ok && len(md["redirect"]) != 0 {
return ctx, status.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
}
if !ok {
md = metadata.New(map[string]string{})
}
md["redirect"] = append(md["redirect"], addr)
return metadata.NewContext(ctx, md), nil
return metadata.NewOutgoingContext(ctx, md), nil
}
remoteMods := []func(context.Context)(context.Context, error){redirectChecker}
remoteMods = append(remoteMods, remoteCtxMod)
Expand Down
8 changes: 4 additions & 4 deletions protobuf/plugin/raftproxy/test/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.