-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Labels
Description
func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) []*model.ServiceInstance { |
A few things wrong here:
- Why do we skip "service without selector" when we find a service? we may have multiple services attached to the same proxy!
- "Headless service without selector" is a misnomer, there is nothing specific to headless service
c.endpoints.GetProxyServiceInstances(proxy)
is broken, it returns all IPs by the service.
For example:
apiVersion: v1
kind: Service
metadata:
labels:
app: shell
name: shell
namespace: default
spec:
ports:
- name: http
port: 9087
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
app: shell
name: shell
namespace: default
subsets:
- addresses:
- ip: 10.244.0.40
nodeName: kind-control-plane
- ip: 10.244.0.41
nodeName: kind-control-plane
ports:
- name: http
port: 9087
protocol: TCP
Both pods will have both IPs as instances!
We should exercise caution in fixing this; I had a misconfig and found c.endpoints.GetProxyServiceInstances(proxy)
taking a ton of CPU