Skip to content

Commit 0e57b81

Browse files
authored
xds: avoid computation when not needed for CDS (istio#50963)
Follow up to istio#50757. This makes the check only occur if the GW actually changed.
1 parent 247709f commit 0e57b81

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pilot/pkg/xds/cds.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,31 @@ func cdsNeedsPush(req *model.PushRequest, proxy *model.Proxy) bool {
9292
return true
9393
}
9494

95-
autoPassthroughModeChanged := proxy.MergedGateway.HasAutoPassthroughGateways() != proxy.PrevMergedGateway.HasAutoPassthroughGateway()
96-
autoPassthroughHostsChanged := !proxy.MergedGateway.GetAutoPassthrughGatewaySNIHosts().Equals(proxy.PrevMergedGateway.GetAutoPassthroughSNIHosts())
95+
checkGateway := false
9796
for config := range req.ConfigsUpdated {
9897
if proxy.Type == model.Router {
9998
if features.FilterGatewayClusterConfig {
10099
if _, f := pushCdsGatewayConfig[config.Kind]; f {
101100
return true
102101
}
103102
}
104-
if config.Kind == kind.Gateway && (autoPassthroughModeChanged || autoPassthroughHostsChanged) {
105-
return true
103+
if config.Kind == kind.Gateway {
104+
// Do the check outside of the loop since its slow; just trigger we need it
105+
checkGateway = true
106106
}
107107
}
108108

109109
if _, f := skippedCdsConfigs[config.Kind]; !f {
110110
return true
111111
}
112112
}
113+
if checkGateway {
114+
autoPassthroughModeChanged := proxy.MergedGateway.HasAutoPassthroughGateways() != proxy.PrevMergedGateway.HasAutoPassthroughGateway()
115+
autoPassthroughHostsChanged := !proxy.MergedGateway.GetAutoPassthrughGatewaySNIHosts().Equals(proxy.PrevMergedGateway.GetAutoPassthroughSNIHosts())
116+
if autoPassthroughModeChanged || autoPassthroughHostsChanged {
117+
return true
118+
}
119+
}
113120
return false
114121
}
115122

0 commit comments

Comments
 (0)