Skip to content

Commit

Permalink
Merge pull request #1159 from alebedev87/dcm-featuregate
Browse files Browse the repository at this point in the history
NE-1790: Enable Dynamic Configuration Manager feature gate
  • Loading branch information
openshift-merge-bot[bot] authored Nov 21, 2024
2 parents 0b561f8 + 9532e78 commit fb5c5d3
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 44 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ require (
// github.com/operator-framework/operator-sdk.
replace (
bitbucket.org/ww/goautoneg => github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d
github.com/openshift/api => github.com/openshift/api v0.0.0-20241004095111-b1f700bdd8d2
github.com/openshift/api => github.com/openshift/api v0.0.0-20241018083007-4f6053f954b0
k8s.io/client-go => k8s.io/client-go v0.31.1
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,8 @@ github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.m
github.com/opencontainers/runtime-spec v0.1.2-0.20190618234442-a950415649c7/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs=
github.com/openshift/api v0.0.0-20241004095111-b1f700bdd8d2 h1:wCRdyt+nHnJsfuLMJF9RW1JK8G4Gvo//gBy6bZI5USE=
github.com/openshift/api v0.0.0-20241004095111-b1f700bdd8d2/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/openshift/api v0.0.0-20241018083007-4f6053f954b0 h1:9CBNaPGycU2dDzq0XoRIqxH0vHZezKDfbINx8e5zH0I=
github.com/openshift/api v0.0.0-20241018083007-4f6053f954b0/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc=
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240/go.mod h1:4riOwdj99Hd/q+iAcJZfNCsQQQMwURnZV6RL4WHYS5w=
github.com/openshift/client-go v0.0.0-20240405120947-c67c8325cdd8 h1:HGfbllzRcrJBSiwzNjBCs7sExLUxC5/1evnvlNGB0Cg=
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/controller/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ type Config struct {
RouteExternalCertificateEnabled bool
IngressControllerLBSubnetsAWSEnabled bool
IngressControllerEIPAllocationsAWSEnabled bool
IngressControllerDCMEnabled bool
}

// reconciler handles the actual ingress reconciliation logic in response to
Expand Down
43 changes: 40 additions & 3 deletions pkg/operator/controller/ingress/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const (

RouterHAProxyConfigManager = "ROUTER_HAPROXY_CONFIG_MANAGER"

RouterHAProxyMaxDynamicServers = "ROUTER_MAX_DYNAMIC_SERVERS"
RouterHAProxyMaxDynamicServersDefaultValue = 1

RouterHAProxyBlueprintRoutePoolSize = "ROUTER_BLUEPRINT_ROUTE_POOL_SIZE"

RouterHAProxyContstats = "ROUTER_HAPROXY_CONTSTATS"

RouterHAProxyThreadsEnvName = "ROUTER_THREADS"
Expand Down Expand Up @@ -121,7 +126,7 @@ func (r *reconciler) ensureRouterDeployment(ci *operatorv1.IngressController, in
if err != nil {
return false, nil, fmt.Errorf("failed to determine if proxy protocol is needed for ingresscontroller %s/%s: %v", ci.Namespace, ci.Name, err)
}
desired, err := desiredRouterDeployment(ci, r.config.IngressControllerImage, ingressConfig, infraConfig, apiConfig, networkConfig, proxyNeeded, haveClientCAConfigmap, clientCAConfigmap, clusterProxyConfig, r.config.RouteExternalCertificateEnabled)
desired, err := desiredRouterDeployment(ci, r.config.IngressControllerImage, ingressConfig, infraConfig, apiConfig, networkConfig, proxyNeeded, haveClientCAConfigmap, clientCAConfigmap, clusterProxyConfig, r.config.RouteExternalCertificateEnabled, r.config.IngressControllerDCMEnabled)
if err != nil {
return haveDepl, current, fmt.Errorf("failed to build router deployment: %v", err)
}
Expand Down Expand Up @@ -243,7 +248,7 @@ func headerValues(values []operatorv1.IngressControllerHTTPHeader) string {
}

// desiredRouterDeployment returns the desired router deployment.
func desiredRouterDeployment(ci *operatorv1.IngressController, ingressControllerImage string, ingressConfig *configv1.Ingress, infraConfig *configv1.Infrastructure, apiConfig *configv1.APIServer, networkConfig *configv1.Network, proxyNeeded bool, haveClientCAConfigmap bool, clientCAConfigmap *corev1.ConfigMap, clusterProxyConfig *configv1.Proxy, routeExternalCertificateEnabled bool) (*appsv1.Deployment, error) {
func desiredRouterDeployment(ci *operatorv1.IngressController, ingressControllerImage string, ingressConfig *configv1.Ingress, infraConfig *configv1.Infrastructure, apiConfig *configv1.APIServer, networkConfig *configv1.Network, proxyNeeded bool, haveClientCAConfigmap bool, clientCAConfigmap *corev1.ConfigMap, clusterProxyConfig *configv1.Proxy, routeExternalCertificateEnabled, ingressControllerDCMEnabled bool) (*appsv1.Deployment, error) {
deployment := manifests.RouterDeployment()
name := controller.RouterDeploymentName(ci)
deployment.Name = name.Name
Expand Down Expand Up @@ -523,6 +528,15 @@ func desiredRouterDeployment(ci *operatorv1.IngressController, ingressController
LoadBalancingAlgorithm string `json:"loadBalancingAlgorithm"`
DynamicConfigManager string `json:"dynamicConfigManager"`
ContStats string `json:"contStats"`
// maxDynamicServers specifies the number of dynamic server slots that will be added to each route.
// This setting can only be configured if dynamicConfigManager is `true`.
// The default value is 1, with a maximum of 10.
// Dynamic server slots help to avoid reloads during endpoint scale-ups. The more dynamic servers
// added, the fewer reloads required when scaling up.
// Note, however, that dynamic servers consume memory even when not enabled.
// Use this analysis of the memory usage to assess the impact of different numbers of servers:
// https://gist.github.com/frobware/2b527ce3f040797909eff482a4776e0b
MaxDynamicServers string `json:"maxDynamicServers"`
}
if len(ci.Spec.UnsupportedConfigOverrides.Raw) > 0 {
if err := json.Unmarshal(ci.Spec.UnsupportedConfigOverrides.Raw, &unsupportedConfigOverrides); err != nil {
Expand Down Expand Up @@ -567,13 +581,36 @@ func desiredRouterDeployment(ci *operatorv1.IngressController, ingressController
})
}

enableDCM := false
if ingressControllerDCMEnabled {
enableDCM = true
}
dynamicConfigOverride := unsupportedConfigOverrides.DynamicConfigManager
if v, err := strconv.ParseBool(dynamicConfigOverride); err == nil && v {
if v, err := strconv.ParseBool(dynamicConfigOverride); err == nil {
// Config override can still be used to opt out from DCM.
enableDCM = v
}

if enableDCM {
env = append(env, corev1.EnvVar{
Name: RouterHAProxyConfigManager,
Value: "true",
}, corev1.EnvVar{
Name: RouterHAProxyBlueprintRoutePoolSize,
Value: "0",
})

// Max dynamic servers override is only taken into account when DCM is enabled.
routerHAProxyMaxDynamicServersValue := RouterHAProxyMaxDynamicServersDefaultValue
if v, err := strconv.Atoi(unsupportedConfigOverrides.MaxDynamicServers); err == nil && v > 0 {
routerHAProxyMaxDynamicServersValue = v
}
env = append(env, corev1.EnvVar{
Name: RouterHAProxyMaxDynamicServers,
Value: strconv.Itoa(routerHAProxyMaxDynamicServersValue),
})
}

contStats := unsupportedConfigOverrides.ContStats
if v, err := strconv.ParseBool(contStats); err == nil && v {
env = append(env, corev1.EnvVar{
Expand Down
Loading

0 comments on commit fb5c5d3

Please sign in to comment.