Keep Service ports added by other writers when the operator updates a Service

Aperta
#7,068 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes

Direzione di ricerca

Find the Service update path for MCPServer, MCPRemoteProxy, and VirtualMCPServer, along with the existing envtest coverage. Read how the operator currently builds and merges Service ports, then add envtest cases for preserving an extra port, dropping a same-number-and-protocol clash, and switching NodePort to ClusterIP. Done when operator ports come first, eligible unnamed or conflicting ports are dropped with Info logs, and kept ports have nodePort set to 0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage

When the operator updates the Service of an MCPServer, MCPRemoteProxy or VirtualMCPServer (for example after a session affinity change, or when the auth server TLS listener is turned on), it replaces the whole port list with the ports it generates. Anything another writer put in that list is lost: an appProtocol set on the http port for a Gateway or load balancer, or extra ports such as a metrics port.

Labels and annotations are already merged rather than replaced, because other controllers write to these Services (GKE NEG adds annotations, for example). Ports could follow the same rule. The drift check for Services only looks at the ports the operator owns, so this concerns the update path only.

Proposed behaviour when the operator updates the port list:

  • The operator's own ports (http, and https-auth when the listener is on) come first, in order, built from the desired state.
  • Other ports are kept in their existing order.
  • A kept port is dropped only if it clashes with an operator port, meaning the same number and the same protocol. Kubernetes allows TCP and UDP on the same number, so matching on the number alone is too broad.
  • A kept port with no name is dropped, because a Service with more than one port needs every port named.
  • nodePort is sent as 0 on every port, including the kept ones. An explicit value breaks changing a VirtualMCPServer Service from NodePort to ClusterIP, because the API server rejects a nodePort on a ClusterIP Service. The API server keeps an already allocated NodePort when an update leaves it out.
  • Log at Info level when a port is dropped, so the loss is visible.

A version of this was written while reviewing the "Expose auth server TLS listener port in operator" pull request (https://github.com/stacklok/toolhive/pull/7065). It was taken out to keep that change to one logical change. When this is picked up, it needs envtest cases for an extra port surviving an update, a clash being dropped, and the NodePort to ClusterIP switch.

Lingua principale
Go
Stelle
2.3k
Fork
326
Merge medio
1g 6h
PR unite (30g)
158

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stacklok/toolhive

Tutte le issue di stacklok/toolhive

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.