fail on error and use ptypes.MarshalAny for now instead of anypb.New

pull/12659/head
R.B. Boyer 3 years ago
parent e4b4f175ed
commit 33fcc83d00

@ -488,7 +488,9 @@ func (s *ResourceGenerator) makeAppCluster(cfgSnap *proxycfg.ConfigSnapshot, nam
protocol = cfg.Protocol protocol = cfg.Protocol
} }
if protocol == "http2" || protocol == "grpc" { if protocol == "http2" || protocol == "grpc" {
s.setHttp2ProtocolOptions(c) if err := s.setHttp2ProtocolOptions(c); err != nil {
return c, err
}
} }
return c, err return c, err
@ -539,7 +541,9 @@ func (s *ResourceGenerator) makeUpstreamClusterForPreparedQuery(upstream structs
OutlierDetection: ToOutlierDetection(cfg.PassiveHealthCheck), OutlierDetection: ToOutlierDetection(cfg.PassiveHealthCheck),
} }
if cfg.Protocol == "http2" || cfg.Protocol == "grpc" { if cfg.Protocol == "http2" || cfg.Protocol == "grpc" {
s.setHttp2ProtocolOptions(c) if err := s.setHttp2ProtocolOptions(c); err != nil {
return c, err
}
} }
} }
@ -744,7 +748,9 @@ func (s *ResourceGenerator) makeUpstreamClustersForDiscoveryChain(
} }
if proto == "http2" || proto == "grpc" { if proto == "http2" || proto == "grpc" {
s.setHttp2ProtocolOptions(c) if err := s.setHttp2ProtocolOptions(c); err != nil {
return nil, err
}
} }
commonTLSContext := makeCommonTLSContextFromLeafWithoutParams(cfgSnap, cfgSnap.Leaf()) commonTLSContext := makeCommonTLSContextFromLeafWithoutParams(cfgSnap, cfgSnap.Leaf())
@ -1040,8 +1046,8 @@ func injectLBToCluster(ec *structs.LoadBalancer, c *envoy_cluster_v3.Cluster) er
return nil return nil
} }
func (s *ResourceGenerator) setHttp2ProtocolOptions(c *envoy_cluster_v3.Cluster) { func (s *ResourceGenerator) setHttp2ProtocolOptions(c *envoy_cluster_v3.Cluster) error {
typedExtensionProtocolOptions := &envoy_upstreams_v3.HttpProtocolOptions{ cfg := &envoy_upstreams_v3.HttpProtocolOptions{
UpstreamProtocolOptions: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_{ UpstreamProtocolOptions: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_{
ExplicitHttpConfig: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig{ ExplicitHttpConfig: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig{
ProtocolConfig: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_Http2ProtocolOptions{ ProtocolConfig: &envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_Http2ProtocolOptions{
@ -1050,10 +1056,13 @@ func (s *ResourceGenerator) setHttp2ProtocolOptions(c *envoy_cluster_v3.Cluster)
}, },
}, },
} }
typedExtensionProtocolOptionsEncoded, err := anypb.New(typedExtensionProtocolOptions) any, err := ptypes.MarshalAny(cfg)
if err != nil { if err != nil {
s.Logger.Warn("failed to convert http protocol options to anypb") return err
}
c.TypedExtensionProtocolOptions = map[string]*anypb.Any{
"envoy.extensions.upstreams.http.v3.HttpProtocolOptions": any,
} }
c.TypedExtensionProtocolOptions = make(map[string]*anypb.Any)
c.TypedExtensionProtocolOptions["envoy.extensions.upstreams.http.v3.HttpProtocolOptions"] = typedExtensionProtocolOptionsEncoded return nil
} }

Loading…
Cancel
Save