Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/network/v1alpha1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ type NetworkGatewayStatus struct {
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// BackendHealthFiltering reports that this node's gateway can leave a
// backend reported Unhealthy out of a NetworkService's Maglev table.
// Every gateway in the namespace applies health only while every
// NetworkGateway there reports it, so all of them build the same table.
// The gateway sets it on every status write; a gateway that cannot apply
// health, an older one included, writes its status without it.
// +optional
BackendHealthFiltering bool `json:"backendHealthFiltering,omitempty"`
}

// NetworkGatewayList is a list of NetworkGateway resources.
Expand Down
20 changes: 18 additions & 2 deletions cmd/galactic-gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ var ipv4ReviewRetry = time.Second
// bindings once no gateway reports it loaded, so a brief API server outage
// while every gateway restarts must not do that.
func resolveIPv4VIPs(ctx context.Context, c client.Client, requested bool) (bool, error) {
return resolveBindingReader(ctx, c, requested, "IPv4 VIPs")
}

// resolveBackendHealth returns whether this process applies backend health:
// requested, from GALACTIC_GATEWAY_BACKEND_HEALTH, and allowed by
// ipv4VIPsAllowed's check of ServiceVIPBinding access, which reading health
// needs as much as IPv4 VIPs do. It behaves as resolveIPv4VIPs does.
func resolveBackendHealth(ctx context.Context, c client.Client, requested bool) (bool, error) {
return resolveBindingReader(ctx, c, requested, "backend health")
}

// resolveBindingReader returns whether feature, which reads ServiceVIPBindings,
// is on: requested and allowed by ipv4VIPsAllowed. A denial is logged and
// turns it off; a review that cannot be made is retried until ctx ends and
// then returned as an error.
func resolveBindingReader(ctx context.Context, c client.Client, requested bool, feature string) (bool, error) {
if !requested {
return false, nil
}
Expand All @@ -162,12 +178,12 @@ func resolveIPv4VIPs(ctx context.Context, c client.Client, requested bool) (bool
return true, nil
case errors.Is(err, errIPv4AccessDenied):
ctrl.Log.WithName("rbac-preflight").Error(err,
"IPv4 VIPs turned off on this node: grant get, list and watch on servicevipbindings and restart")
feature+" turned off on this node: grant get, list and watch on servicevipbindings and restart")
return false, nil
}
select {
case <-ctx.Done():
return false, fmt.Errorf("could not confirm access for IPv4 VIPs: %w", err)
return false, fmt.Errorf("could not confirm access for %s: %w", feature, err)
case <-time.After(ipv4ReviewRetry):
}
}
Expand Down
32 changes: 21 additions & 11 deletions cmd/galactic-gateway/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ func runCmd(cfg *config.GatewayConfig) error {
// Pre-flight RBAC check.
checkWatchPermissions(mgr)

// IPv4 VIPs need read access to ServiceVIPBindings; without it they stay
// off for this process rather than stalling the manager's cache. A check
// that cannot be made fails startup instead, so the restart checks again.
// IPv4 VIPs and backend health need read access to ServiceVIPBindings;
// without it they stay off for this process rather than stalling the
// manager's cache. A check that cannot be made fails startup instead, so
// the restart checks again.
reviewCtx, cancelReview := context.WithTimeout(ctx, 30*time.Second)
ipv4VIPs, err := resolveIPv4VIPs(reviewCtx, mgr.GetClient(), cfg.IPv4VIPs)
if err != nil {
cancelReview()
return err
}
backendHealth, err := resolveBackendHealth(reviewCtx, mgr.GetClient(), cfg.BackendHealth)
cancelReview()
if err != nil {
return err
Expand Down Expand Up @@ -198,14 +204,15 @@ func runCmd(cfg *config.GatewayConfig) error {
// rewrites nothing, so a gateway node has no translation source of its own
// to publish.
if err := (&controller.NetworkGatewayReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Engine: gwEngine,
NodeName: nodeName,
APIReader: mgr.GetAPIReader(),
Disabled: !cfg.DatapathEnabled,
ReturnPath: returnPath,
IPv4VIPs: ipv4VIPs,
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Engine: gwEngine,
NodeName: nodeName,
APIReader: mgr.GetAPIReader(),
Disabled: !cfg.DatapathEnabled,
ReturnPath: returnPath,
IPv4VIPs: ipv4VIPs,
BackendHealth: backendHealth,
// Forwarding follows need: on only once an IPv4 VIP is about to load.
EnsureIPv4Forwarding: ipv4.enable,
}).SetupWithManager(mgr); err != nil {
Expand Down Expand Up @@ -307,6 +314,9 @@ func newRootCommand() *cobra.Command {
cmd.Flags().Bool("gateway-ipv4-vips", false,
"Serve IPv4 VIPs: load them over the rule's IPv6 backends, which translate them, and advertise "+
"each once its backends' ServiceVIPBindings are Bound")
cmd.Flags().Bool("gateway-backend-health", false,
"Leave a backend its node reports Unhealthy out of the rule's Maglev table, once every gateway "+
"in the namespace does the same")
cmd.Flags().String("gateway-proc-sys-path", config.DefaultProcSysPath,
"Procfs sysctl root to write the datapath's forwarding sysctls under, such as a writable mount "+
"of the host's /proc/sys/net at <path>/net")
Expand Down
9 changes: 9 additions & 0 deletions config/crd/galactic.datumapis.com_networkgateways.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ spec:
status:
description: NetworkGatewayStatus defines the observed state of a NetworkGateway.
properties:
backendHealthFiltering:
description: |-
BackendHealthFiltering reports that this node's gateway can leave a
backend reported Unhealthy out of a NetworkService's Maglev table.
Every gateway in the namespace applies health only while every
NetworkGateway there reports it, so all of them build the same table.
The gateway sets it on every status write; a gateway that cannot apply
health, an older one included, writes its status without it.
type: boolean
conditions:
description: Conditions contains the standard conditions for this
resource.
Expand Down
1 change: 1 addition & 0 deletions deploy/containerlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ task deploy
| `verify:gateway` | Check every NetworkGateway is Ready, every NetworkService Accepted, every generated ServiceVIPBinding Bound |
| `verify:gateway-ingress` | TCP and UDP from the off-fabric host to each site's VIP, through every gateway node in turn |
| `verify:gateway-ingress-ipv4` | IPv4 TCP and UDP to each site's IPv4 VIP through every gateway node, translated to the IPv6-only backends |
| `verify:gateway-backend-health` | Stops a dfw backend's listener; both gateways must drop it, keep it out across restarts, and take it back once it listens |
| `verify:gateway-node-loss` | Take dfw-worker2's fabric links down: ingress through dfw-worker3 must pass, then through dfw-worker2 once restored (not in `verify`) |
| `verify:gateway-restart` | Restart dfw-worker2's gateway and shard in turn while the other carries traffic (#710) |
| `verify:gateway-detach` | Turn dfw-worker2's gateway datapath off: ingress through it must fail and through dfw-worker3 pass, then through it pass (not in `verify`) |
Expand Down
11 changes: 11 additions & 0 deletions deploy/containerlab/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ tasks:
- task: "verify:gateway"
- task: "verify:gateway-ingress"
- task: "verify:gateway-ingress-ipv4"
- task: "verify:gateway-backend-health"
- task: "verify:gateway-restart"
- task: "verify:nat-sharding"
- task: "verify:nat-egress"
Expand Down Expand Up @@ -616,6 +617,16 @@ tasks:
cmds:
- LAB={{.LAB}} ./scripts/verify-gateway-ingress-ipv4.sh

# dfw's VIP drops a backend whose listener stops while its pod stays up,
# on both gateway nodes and with no operator action, keeps it out across a
# galactic-router and a galactic-gateway restart, and takes it back once it
# listens again. Fixed client ports must map to the same backend through
# both gateways, and back where they were after recovery.
"verify:gateway-backend-health":
desc: Stop one dfw backend's listener and check both gateways drop it, then restore it
cmds:
- LAB={{.LAB}} ./scripts/verify-gateway-backend-health.sh

# #710: the gateway and the egress shard share each edge node's uplinks
# through its XDP dispatcher, so restarting either must leave the other's
# traffic flowing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ spec:
# it needs (verify:gateway-ingress-ipv4).
- name: GALACTIC_GATEWAY_IPV4_VIPS
value: "true"
# Off by default. Every lab gateway takes a backend its node
# reports Unhealthy out of ns60's services, which carry a
# healthCheck (verify:gateway-backend-health). The same binding
# access as IPv4 VIPs covers it.
- name: GALACTIC_GATEWAY_BACKEND_HEALTH
value: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
matchLabels:
app: backend
backendPort: 80
# Each backend's node probes it on backendPort (verify:gateway-backend-health).
healthCheck: {}
---
# ns60's port 80 over UDP, served by every ns60 backend its selector picks in dfw.
# Both VIPs reach the same IPv6-only backends: the backend's node translates
Expand All @@ -37,3 +39,6 @@ spec:
matchLabels:
app: backend
backendPort: 80
# A UDP service names a TCP port to probe: the backends answer TCP on 80 too.
healthCheck:
port: 80
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
matchLabels:
app: backend
backendPort: 80
# Each backend's node probes it on backendPort (verify:gateway-backend-health).
healthCheck: {}
---
# ns60's port 80 over UDP, served by every ns60 backend its selector picks in iad.
# Both VIPs reach the same IPv6-only backends: the backend's node translates
Expand All @@ -37,3 +39,6 @@ spec:
matchLabels:
app: backend
backendPort: 80
# A UDP service names a TCP port to probe: the backends answer TCP on 80 too.
healthCheck:
port: 80
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
matchLabels:
app: backend
backendPort: 80
# Each backend's node probes it on backendPort (verify:gateway-backend-health).
healthCheck: {}
---
# ns60's port 80 over UDP, served by every ns60 backend its selector picks in sjc.
# Both VIPs reach the same IPv6-only backends: the backend's node translates
Expand All @@ -37,3 +39,6 @@ spec:
matchLabels:
app: backend
backendPort: 80
# A UDP service names a TCP port to probe: the backends answer TCP on 80 too.
healthCheck:
port: 80
10 changes: 5 additions & 5 deletions deploy/containerlab/resources/tenants/policies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ in `resources/galactic-cni/shared/`), so a tenant interface forwards only what
its bindings grant. These are the grants, one set per kind of tenant, each an
ingress and an egress policy granting only the paths that tenant's checks use:

| Set | Tenants | Egress grants | Ingress grants |
| ---------------- | ---------------------- | ------------------ | --------------------------------- |
| `private-nat` | ns10, ns20, ns30, ns71 | Private, PublicNAT | Private (except TCP 9), PublicNAT |
| `private` | ns40 | Private | Private (except TCP 9) |
| `public-service` | ns60 | PublicService | PublicService |
| Set | Tenants | Egress grants | Ingress grants |
| ---------------- | ---------------------- | ------------------------------------------------------ | ------------------------------------------------------ |
| `private-nat` | ns10, ns20, ns30, ns71 | Private, PublicNAT | Private (except TCP 9), PublicNAT |
| `private` | ns40 | Private | Private (except TCP 9) |
| `public-service` | ns60 | PublicService, Private TCP from port 80 to `fe80::/10` | PublicService, Private TCP to port 80 from `fe80::/10` |

The TCP 9 deny on Private ingress, and every path a set leaves out, are what
`verify:traffic-policy` uses to prove a denial is enforced and counted. Each
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# ns60's VIP backends: they receive the gateways' public service traffic and
# answer it, and nothing else (verify:gateway-ingress). verify:traffic-policy
# inserts a temporary deny ahead of allow-service to prove a denial on this
# path, then restores this policy.
# answer it, and the TCP health probes their own node sends from its host-side
# link-local address, and nothing else (verify:gateway-ingress,
# verify:gateway-backend-health). verify:traffic-policy inserts a temporary
# deny ahead of allow-service to prove a denial on this path, then restores
# this policy.
apiVersion: galactic.datumapis.com/v1alpha1
kind: TrafficPolicy
metadata:
Expand All @@ -12,6 +14,13 @@ spec:
action: Allow
match:
path: PublicService
- name: allow-health-probe-replies
action: Allow
match:
path: Private
protocol: TCP
destinationCIDRs: ["fe80::/10"]
sourcePorts: [{start: 80, end: 80}]
---
apiVersion: galactic.datumapis.com/v1alpha1
kind: TrafficPolicy
Expand All @@ -23,3 +32,10 @@ spec:
action: Allow
match:
path: PublicService
- name: allow-health-probe
action: Allow
match:
path: Private
protocol: TCP
sourceCIDRs: ["fe80::/10"]
destinationPorts: [{start: 80, end: 80}]
Loading
Loading