add Ports field in GatewayClient and enforce Port/Ports coherence#3233
add Ports field in GatewayClient and enforce Port/Ports coherence#3233MircoBarone wants to merge 4 commits intoliqotech:masterfrom
Conversation
|
Hi @MircoBarone. Thanks for your PR! I am @adamjensenbot.
Make sure this PR appears in the liqo changelog, adding one of the following labels:
|
d678438 to
e9bae96
Compare
e9bae96 to
dbc13ad
Compare
|
I have removed the coherence check ( The logic is now handled via CEL validation: if both Potential Issues
I believe these issues can be solved by using a more robust template, for example: - --endpoint-port={{ if .Spec.Endpoint.Port }}{{ .Spec.Endpoint.Port }}{{ else if .Spec.Endpoint.Ports }}{{ index .Spec.Endpoint.Ports 0 }}{{ end }}
- --endpoint-ports={{ if .Spec.Endpoint.Ports }}{{ range $i, $p := .Spec.Endpoint.Ports }}{{ if $i }},{{ end }}{{ $p }}{{ end }}{{ else }}{{ .Spec.Endpoint.Port }}{{ end }}I am moving this PR out of draft. Let me know if you think a Mutating Webhook is strictly necessary or if this CEL-based approach is sufficient. In my opinion, this approach can also serve as a base if we want to introduce mutation in the future |
Description
Part of the multi-tunnel WireGuard implementation. This is the 3rd PR related to issue #3225.
The
Portsfield was introduced inGatewayClientSpec. The idea is to store the list of endpoint ports that the gateway server has exposed for the WireGuard interfaces.Portsis not meant to replace the legacyPortfield, which is kept for backward compatibility. The invariant is thatPorts[0]must always be equal toPort.To enforce this, a new function
EnsurePortsCoherencewas added to theClientReconciler. At the beginning of each reconcile cycle, this function checks whetherPortandPortsare consistent. If not, it normalizes them according to the following rules:Portis specified,Portsis set to[]int32{Port}Portsis specified,Portis overwritten withPorts[0]After normalization, the resource is updated and the reconcile cycle is requeued.