Skip to content

Commit

Permalink
fix failover gw [1.13] (#8665)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshu authored Sep 8, 2023
1 parent fe0f72d commit de7990e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion install/helm/gloo/templates/_8-default-gateways.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ spec:
{{- if $spec.failover.enabled }}
{{- $failoverGatewayOverride := $spec.failover.kubeResourceOverride }}
---
{{- include "gloo.util.merge" (list $ctx $failoverGatewayOverride "defaultGateway.failoverGateway") -}}
{{ include "gloo.util.merge" (list $ctx $failoverGatewayOverride "defaultGateway.failoverGateway") -}}
{{- end }}{{/* if $spec.failover.enabled */}}
{{- end }}{{/* if $spec.failover */}}
{{- end }}{{/* if $spec.gatewaySettings and (not $spec.disabled) */}}
Expand Down
48 changes: 44 additions & 4 deletions install/test/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5893,6 +5893,8 @@ metadata:
valuesArgs: []string{
"gatewayProxies.gatewayProxy.gatewaySettings.httpGatewayKubeOverride.spec.bindPort=1234",
"gatewayProxies.gatewayProxy.gatewaySettings.httpsGatewayKubeOverride.spec.ssl=false",
"gatewayProxies.gatewayProxy.failover.enabled=true",
"gatewayProxies.gatewayProxy.failover.kubeResourceOverride.spec.bindPort=5678",
},
})
// expected gateways
Expand All @@ -5904,10 +5906,15 @@ metadata:
unstructured.SetNestedField(gwSsl.Object,
false,
"spec", "ssl")
gwFailover := makeUnstructuredFailoverGateway(namespace, defaults.GatewayProxyName)
unstructured.SetNestedField(gwFailover.Object,
int64(5678),
"spec", "bindPort")

assertCustomResourceManifest(map[string]types.GomegaMatcher{
defaults.GatewayProxyName: BeEquivalentTo(gw),
getSslGatewayName(defaults.GatewayProxyName): BeEquivalentTo(gwSsl),
defaults.GatewayProxyName: BeEquivalentTo(gw),
getSslGatewayName(defaults.GatewayProxyName): BeEquivalentTo(gwSsl),
getFailoverGatewayName(defaults.GatewayProxyName): BeEquivalentTo(gwFailover),
})
})

Expand All @@ -5917,6 +5924,8 @@ metadata:
"gatewayProxies.gatewayProxy.disabled=true",
"gatewayProxies.anotherProxy.gatewaySettings.httpGatewayKubeOverride.spec.bindAddress=something",
"gatewayProxies.anotherProxy.gatewaySettings.httpsGatewayKubeOverride.spec.proxyNames[0]=new-proxy",
"gatewayProxies.anotherProxy.failover.enabled=true",
"gatewayProxies.anotherProxy.failover.kubeResourceOverride.spec.bindPort=5678",
},
})
// expected gateways
Expand All @@ -5928,10 +5937,15 @@ metadata:
unstructured.SetNestedStringSlice(anotherGwSsl.Object,
[]string{"new-proxy"},
"spec", "proxyNames")
anotherGwFailover := makeUnstructuredFailoverGateway(namespace, "another-proxy")
unstructured.SetNestedField(anotherGwFailover.Object,
int64(5678),
"spec", "bindPort")

assertCustomResourceManifest(map[string]types.GomegaMatcher{
"another-proxy": BeEquivalentTo(anotherGw),
getSslGatewayName("another-proxy"): BeEquivalentTo(anotherGwSsl),
"another-proxy": BeEquivalentTo(anotherGw),
getSslGatewayName("another-proxy"): BeEquivalentTo(anotherGwSsl),
getFailoverGatewayName("another-proxy"): BeEquivalentTo(anotherGwFailover),
})
})
})
Expand Down Expand Up @@ -6129,6 +6143,32 @@ spec:
`)
}

func makeUnstructuredFailoverGateway(namespace string, proxyName string) *unstructured.Unstructured {
return makeUnstructured(`
apiVersion: gateway.solo.io/v1
kind: Gateway
metadata:
labels:
app: gloo
name: ` + getFailoverGatewayName(proxyName) + `
namespace: ` + namespace + `
spec:
bindAddress: '::'
bindPort: 15443
proxyNames:
- ` + proxyName + `
tcpGateway:
tcpHosts:
- destination:
forwardSniClusterName: {}
name: failover
sslConfig:
secretRef:
name: failover-downstream
namespace: ` + namespace + `
`)
}

func getSslGatewayName(name string) string {
return name + "-ssl"
}
Expand Down

0 comments on commit de7990e

Please sign in to comment.