mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
fix(vm-instance): keep an external PortList VM valid with no ports
The API server rejects a Service that declares no port, so a VM switched to external PortList with an empty port list could not be upgraded: the release failed and was retried forever, while the old Service kept the previously listed ports open. Render a single SCTP placeholder in that case. cozy-proxy only admits TCP and UDP ports into its PortList filter, so the VM keeps its external IP for egress and ICMP while all inbound TCP and UDP traffic is dropped, which is what an empty port list means. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
2 files changed
+77
No files matched your search
@@ -30,6 +30,13 @@ spec:
|
||||
{{- if .Values.external }}
|
||||
{{- if and (eq .Values.externalMethod "WholeIP") (not .Values.externalPorts) }}
|
||||
- port: 65535
|
||||
{{- else if not .Values.externalPorts }}
|
||||
{{- /* A Service needs at least one port. cozy-proxy only admits TCP and
|
||||
UDP ports into its PortList filter, so an SCTP placeholder keeps the
|
||||
external IP while every inbound TCP and UDP packet is dropped. */}}
|
||||
- name: no-ports
|
||||
port: 65535
|
||||
protocol: SCTP
|
||||
{{- else }}
|
||||
{{- range .Values.externalPorts }}
|
||||
- name: port-{{ . }}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
suite: vm-instance external Service ports
|
||||
|
||||
# The API server rejects a Service without ports, so an external PortList VM
|
||||
# whose port list was emptied could not be upgraded at all. The placeholder
|
||||
# must be SCTP: cozy-proxy only admits TCP and UDP ports into its filter, so
|
||||
# any TCP or UDP placeholder would open that port on the VM.
|
||||
release:
|
||||
name: test-vm
|
||||
namespace: tenant-test
|
||||
templates:
|
||||
- templates/service.yaml
|
||||
set:
|
||||
fullnameOverride: test-vm
|
||||
external: true
|
||||
|
||||
tests:
|
||||
- it: renders an SCTP placeholder for PortList with no ports
|
||||
set:
|
||||
externalMethod: PortList
|
||||
externalPorts: []
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.type
|
||||
value: LoadBalancer
|
||||
- equal:
|
||||
path: metadata.annotations["networking.cozystack.io/wholeIP"]
|
||||
value: "false"
|
||||
- lengthEqual:
|
||||
path: spec.ports
|
||||
count: 1
|
||||
- equal:
|
||||
path: spec.ports[0]
|
||||
value:
|
||||
name: no-ports
|
||||
port: 65535
|
||||
protocol: SCTP
|
||||
|
||||
- it: renders the listed ports for PortList
|
||||
set:
|
||||
externalMethod: PortList
|
||||
externalPorts: [22, 443]
|
||||
asserts:
|
||||
- lengthEqual:
|
||||
path: spec.ports
|
||||
count: 2
|
||||
- equal:
|
||||
path: spec.ports[0]
|
||||
value:
|
||||
name: port-22
|
||||
port: 22
|
||||
targetPort: 22
|
||||
- notContains:
|
||||
path: spec.ports
|
||||
content:
|
||||
name: no-ports
|
||||
port: 65535
|
||||
protocol: SCTP
|
||||
|
||||
- it: keeps the WholeIP placeholder when no ports are listed
|
||||
set:
|
||||
externalMethod: WholeIP
|
||||
externalPorts: []
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["networking.cozystack.io/wholeIP"]
|
||||
value: "true"
|
||||
- equal:
|
||||
path: spec.ports
|
||||
value:
|
||||
- port: 65535
|
||||
Reference in new issue
Block a user