Skip to content

GetProxyServiceInstances has questionable logic #45241

@howardjohn

Description

@howardjohn

func (c *Controller) GetProxyServiceInstances(proxy *model.Proxy) []*model.ServiceInstance {

A few things wrong here:

  1. Why do we skip "service without selector" when we find a service? we may have multiple services attached to the same proxy!
  2. "Headless service without selector" is a misnomer, there is nothing specific to headless service
  3. 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions