Commit 647edc6c authored by Miciah Masters's avatar Miciah Masters Committed by Miciah Dashiel Butler Masters
Browse files

Configure router to use "source" for passthrough

Configure OpenShift router to use the "source" balancing algorithm for
passthrough routes in order to provide some session-affinity.

This was the behavior for passthrough routes before OpenShift 4.8, and
changing it was unintentional.

Follow-up to commit e83b057c.

This commit fixes bug 1997407.

https://bugzilla.redhat.com/show_bug.cgi?id=1997407

* pkg/operator/controller/ingress/deployment.go
(RouterTCPLoadBalancingAlgorithmEnvName): New const for the
"ROUTER_TCP_BALANCE_SCHEME" environment variable.
(desiredRouterDeployment): Set ROUTER_TCP_BALANCE_SCHEME to "source".
* pkg/operator/controller/ingress/deployment_test.go
(TestDesiredRouterDeployment): Verify that desiredRouterDeployment sets
ROUTER_TCP_BALANCE_SCHEME appropriately.
parent e9e62957
......@@ -57,7 +57,8 @@ const (
RouterHeaderBufferSize = "ROUTER_BUF_SIZE"
RouterHeaderBufferMaxRewriteSize = "ROUTER_MAX_REWRITE_SIZE"
RouterLoadBalancingAlgorithmEnvName = "ROUTER_LOAD_BALANCE_ALGORITHM"
RouterLoadBalancingAlgorithmEnvName = "ROUTER_LOAD_BALANCE_ALGORITHM"
RouterTCPLoadBalancingAlgorithmEnvName = "ROUTER_TCP_BALANCE_SCHEME"
RouterDisableHTTP2EnvName = "ROUTER_DISABLE_HTTP2"
RouterDefaultEnableHTTP2Annotation = "ingress.operator.openshift.io/default-enable-http2"
......@@ -416,6 +417,11 @@ func desiredRouterDeployment(ci *operatorv1.IngressController, ingressController
return nil, fmt.Errorf("ingresscontroller %q has invalid spec.unsupportedConfigOverrides: %w", ci.Name, err)
}
}
// For non-TLS, edge-terminated, and reencrypt routes, use the "random"
// balancing algorithm by default, but allow an unsupported config
// override to override it. For passthrough routes, use the "source"
// balancing algorithm in order to provide some session-affinity.
loadBalancingAlgorithm := "random"
switch unsupportedConfigOverrides.LoadBalancingAlgorithm {
case "leastconn":
......@@ -424,6 +430,9 @@ func desiredRouterDeployment(ci *operatorv1.IngressController, ingressController
env = append(env, corev1.EnvVar{
Name: RouterLoadBalancingAlgorithmEnvName,
Value: loadBalancingAlgorithm,
}, corev1.EnvVar{
Name: RouterTCPLoadBalancingAlgorithmEnvName,
Value: "source",
})
if len(ci.Status.Domain) > 0 {
......
......@@ -219,6 +219,7 @@ func TestDesiredRouterDeployment(t *testing.T) {
}
checkDeploymentHasEnvVar(t, deployment, "ROUTER_LOAD_BALANCE_ALGORITHM", true, "random")
checkDeploymentHasEnvVar(t, deployment, "ROUTER_TCP_BALANCE_SCHEME", true, "source")
checkDeploymentHasEnvVar(t, deployment, "ROUTER_USE_PROXY_PROTOCOL", false, "")
......@@ -378,6 +379,7 @@ func TestDesiredRouterDeployment(t *testing.T) {
}
checkDeploymentHasEnvVar(t, deployment, "ROUTER_LOAD_BALANCE_ALGORITHM", true, "leastconn")
checkDeploymentHasEnvVar(t, deployment, "ROUTER_TCP_BALANCE_SCHEME", true, "source")
checkDeploymentHasEnvVar(t, deployment, "ROUTER_USE_PROXY_PROTOCOL", true, "true")
......@@ -447,6 +449,7 @@ func TestDesiredRouterDeployment(t *testing.T) {
}
checkDeploymentHasEnvVar(t, deployment, "ROUTER_LOAD_BALANCE_ALGORITHM", true, "random")
checkDeploymentHasEnvVar(t, deployment, "ROUTER_TCP_BALANCE_SCHEME", true, "source")
checkDeploymentDoesNotHaveEnvVar(t, deployment, "ROUTER_USE_PROXY_PROTOCOL")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment