Skip to content

Commit b8aaffd

Browse files
committed
add feature flag and release note
1 parent 72ec1b9 commit b8aaffd

4 files changed

Lines changed: 46 additions & 3 deletions

File tree

pilot/pkg/features/pilot.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ var (
275275
" (e.g., my-service.my-ns.svc.cluster.local.) to the domains"+
276276
" list for VirtualHost entries.",
277277
).Get()
278+
279+
EnableProxyFindPodByIP = env.Register("ENABLE_PROXY_FIND_POD_BY_IP", false,
280+
"If enabled, the pod controller will allow findig pods matching proxies by IP if it fails to find them by name.").Get()
278281
)
279282

280283
// UnsafeFeaturesEnabled returns true if any unsafe features are enabled.

pilot/pkg/serviceregistry/kube/controller/pod.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,5 +356,31 @@ func (pc *PodCache) getPodByProxy(proxy *model.Proxy) *v1.Pod {
356356
}
357357
}
358358

359+
if features.EnableProxyFindPodByIP {
360+
// only need to fetch the corresponding pod through the first IP, although there are multiple IP scenarios,
361+
// because multiple ips belong to the same pod
362+
proxyIP := proxy.IPAddresses[0]
363+
// just in case the proxy ID is bad formatted
364+
pods := pc.getPodsByIP(proxyIP)
365+
switch len(pods) {
366+
case 0:
367+
return nil
368+
case 1:
369+
return pods[0]
370+
default:
371+
// This should only happen with hostNetwork pods, which cannot be proxy clients...
372+
log.Errorf("unexpected: found multiple pods for proxy %v (%v)", proxy.ID, proxyIP)
373+
// Try to handle it gracefully
374+
for _, p := range pods {
375+
// At least filter out wrong namespaces...
376+
if proxy.ConfigNamespace != p.Namespace {
377+
continue
378+
}
379+
return p
380+
}
381+
return nil
382+
}
383+
}
384+
359385
return nil
360386
}

pilot/pkg/serviceregistry/kube/controller/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ func isNodePortGatewayService(svc *v1.Service) bool {
150150

151151
// Get the pod key of the proxy which can be used to get pod from the informer cache
152152
func podKeyByProxy(proxy *model.Proxy) types.NamespacedName {
153-
parts := strings.Split(proxy.ID, ".")
154-
if len(parts) == 2 && proxy.Metadata.Namespace == parts[1] {
155-
return types.NamespacedName{Name: parts[0], Namespace: parts[1]}
153+
name, namespace, ok := strings.Cut(proxy.ID, ".")
154+
if ok && proxy.Metadata.Namespace == namespace {
155+
return types.NamespacedName{Name: name, Namespace: namespace}
156156
}
157157

158158
return types.NamespacedName{}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: release-notes/v2
2+
kind: feature
3+
area: traffic-management
4+
releaseNotes:
5+
- |
6+
**Added** feature ENABLE_PROXY_FIND_POD_BY_IP that allows to enable association of Pods to Proxies by IP address if association by name and namespace fails.
7+
8+
upgradeNodes:
9+
- title: Change in behaviour of how Istio finds matching Pods for a given Proxy
10+
content: |
11+
In previous versions, Istio would search for matching Pods for a given Proxy by IP address when it failed to find
12+
them by name and namespace. This behaviour is now disabled by default and can be enabled using the
13+
`ENABLE_PROXY_FIND_POD_BY_IP` feature flag. This will only impact users who are customizing the Istio Proxy and that
14+
are not correctly setting the Proxy ID and Metadata required to find the worload name. For context see https://github.com/istio/istio/pull/56502

0 commit comments

Comments
 (0)