Fixed a few tautological condition mistakes (#6177)

None of these changes should have any side-effects. They're merely
fixing tautological mistakes.
This commit is contained in:
Christian Muehlhaeuser 2019-07-19 13:53:42 +02:00 committed by Matt Keeler
parent d1426767f6
commit 877bfd280b
3 changed files with 24 additions and 26 deletions

View File

@ -67,7 +67,7 @@ func (probe *GrpcHealthProbe) Check() error {
if err != nil { if err != nil {
return err return err
} }
if response == nil || (response != nil && response.Status != hv1.HealthCheckResponse_SERVING) { if response == nil || response.Status != hv1.HealthCheckResponse_SERVING {
return ErrGRPCUnhealthy return ErrGRPCUnhealthy
} }

View File

@ -90,7 +90,7 @@ func (r *aclTokenReplicator) DeleteLocalBatch(srv *Server, batch []string) error
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok && err != nil { if respErr, ok := resp.(error); ok {
return respErr return respErr
} }
return nil return nil
@ -119,7 +119,7 @@ func (r *aclTokenReplicator) UpdateLocalBatch(ctx context.Context, srv *Server,
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok && err != nil { if respErr, ok := resp.(error); ok {
return respErr return respErr
} }
@ -202,7 +202,7 @@ func (r *aclPolicyReplicator) DeleteLocalBatch(srv *Server, batch []string) erro
if err != nil { if err != nil {
return err return err
} }
if respErr, ok := resp.(error); ok && err != nil { if respErr, ok := resp.(error); ok {
return respErr return respErr
} }
return nil return nil

View File

@ -60,31 +60,29 @@ func (s *Server) makeAppCluster(cfgSnap *proxycfg.ConfigSnapshot) (*envoy.Cluste
return makeClusterFromUserConfig(cfg.LocalClusterJSON) return makeClusterFromUserConfig(cfg.LocalClusterJSON)
} }
if c == nil { addr := cfgSnap.Proxy.LocalServiceAddress
addr := cfgSnap.Proxy.LocalServiceAddress if addr == "" {
if addr == "" { addr = "127.0.0.1"
addr = "127.0.0.1" }
} c = &envoy.Cluster{
c = &envoy.Cluster{ Name: LocalAppClusterName,
Name: LocalAppClusterName, ConnectTimeout: time.Duration(cfg.LocalConnectTimeoutMs) * time.Millisecond,
ConnectTimeout: time.Duration(cfg.LocalConnectTimeoutMs) * time.Millisecond, ClusterDiscoveryType: &envoy.Cluster_Type{Type: envoy.Cluster_STATIC},
ClusterDiscoveryType: &envoy.Cluster_Type{Type: envoy.Cluster_STATIC}, LoadAssignment: &envoy.ClusterLoadAssignment{
LoadAssignment: &envoy.ClusterLoadAssignment{ ClusterName: LocalAppClusterName,
ClusterName: LocalAppClusterName, Endpoints: []envoyendpoint.LocalityLbEndpoints{
Endpoints: []envoyendpoint.LocalityLbEndpoints{ {
{ LbEndpoints: []envoyendpoint.LbEndpoint{
LbEndpoints: []envoyendpoint.LbEndpoint{ makeEndpoint(LocalAppClusterName,
makeEndpoint(LocalAppClusterName, addr,
addr, cfgSnap.Proxy.LocalServicePort),
cfgSnap.Proxy.LocalServicePort),
},
}, },
}, },
}, },
} },
if cfg.Protocol == "http2" || cfg.Protocol == "grpc" { }
c.Http2ProtocolOptions = &envoycore.Http2ProtocolOptions{} if cfg.Protocol == "http2" || cfg.Protocol == "grpc" {
} c.Http2ProtocolOptions = &envoycore.Http2ProtocolOptions{}
} }
return c, err return c, err