so-ad7: build per-pod Service for maintenance container

get_services() now also includes the container named by
maintenance-service: in its container_ports map, so the
maintenance pod's {app_name}-{pod_name}-service gets created
permanently. _restart_with_maintenance can then swap Ingress
backends to a real Service that has Endpoints.

The Service is only externally reachable during the Ingress swap
window; outside of that, no Ingress rule routes to it, so it sits
idle as a warm standby (matching the maintenance pod itself).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pull/744/head
Prathamesh Musale 2026-04-16 07:27:59 +00:00
parent 79bae5bf9d
commit 7256d47199
1 changed files with 15 additions and 5 deletions

View File

@ -954,13 +954,18 @@ class ClusterInfo:
svc = self.get_service()
return [svc] if svc else []
# Multi-pod: one service per pod, only for pods that have
# ports referenced by http-proxy routes
http_proxy_list = self.spec.get_http_proxy()
if not http_proxy_list:
# Multi-pod: one service per pod, only for pods whose containers
# are referenced by http-proxy routes or by maintenance-service.
http_proxy_list = self.spec.get_http_proxy() or []
maintenance_svc = self.spec.get_maintenance_service()
if not http_proxy_list and not maintenance_svc:
return []
# Build map: container_name -> port from http-proxy routes
# Build map: container_name -> set of ports. Sources:
# - http-proxy routes (normal traffic routing)
# - maintenance-service (so _restart_with_maintenance can swap
# Ingress backends to a real Service during the maintenance
# window; the maintenance pod has no http-proxy route by design)
container_ports: dict = {}
for http_proxy in http_proxy_list:
for route in http_proxy.get("routes", []):
@ -971,6 +976,11 @@ class ClusterInfo:
if container not in container_ports:
container_ports[container] = set()
container_ports[container].add(port)
if maintenance_svc and ":" in maintenance_svc:
maint_container, maint_port_str = maintenance_svc.split(":", 1)
container_ports.setdefault(maint_container, set()).add(
int(maint_port_str)
)
# Build map: pod_file -> set of service names in that pod
pod_services_map: dict = {}