diff --git a/pkg/3scale/amp/component/backend.go b/pkg/3scale/amp/component/backend.go index 8e14eb209..5be95b864 100644 --- a/pkg/3scale/amp/component/backend.go +++ b/pkg/3scale/amp/component/backend.go @@ -417,6 +417,7 @@ func (backend *Backend) buildBackendListenerEnv() []v1.EnvVar { result := []v1.EnvVar{} result = append(result, backend.buildBackendCommonEnv()...) result = append(result, + helper.EnvVarFromValue("CONFIG_REDIS_ASYNC", "1"), helper.EnvVarFromValue("PUMA_WORKERS", "16"), helper.EnvVarFromSecret("CONFIG_INTERNAL_API_USER", BackendSecretInternalApiSecretName, BackendSecretInternalApiUsernameFieldName), helper.EnvVarFromSecret("CONFIG_INTERNAL_API_PASSWORD", BackendSecretInternalApiSecretName, BackendSecretInternalApiPasswordFieldName), diff --git a/pkg/3scale/amp/operator/backend_reconciler.go b/pkg/3scale/amp/operator/backend_reconciler.go index e962aabc2..19e25a532 100644 --- a/pkg/3scale/amp/operator/backend_reconciler.go +++ b/pkg/3scale/amp/operator/backend_reconciler.go @@ -39,6 +39,7 @@ func (r *BackendReconciler) Reconcile() (reconcile.Result, error) { // Listener DC listenerConfigMutator := reconcilers.GenericBackendMutators() + listenerConfigMutator = append(listenerConfigMutator, reconcilers.DeploymentConfigEnvMutator) if r.apiManager.Spec.Backend.ListenerSpec.Replicas != nil { listenerConfigMutator = append(listenerConfigMutator, reconcilers.DeploymentConfigReplicasMutator) } @@ -62,6 +63,7 @@ func (r *BackendReconciler) Reconcile() (reconcile.Result, error) { // Worker DC workerConfigMutator := reconcilers.GenericBackendMutators() + workerConfigMutator = append(workerConfigMutator, reconcilers.DeploymentConfigEnvMutator) if r.apiManager.Spec.Backend.WorkerSpec.Replicas != nil { workerConfigMutator = append(workerConfigMutator, reconcilers.DeploymentConfigReplicasMutator) } diff --git a/pkg/reconcilers/deploymentconfig.go b/pkg/reconcilers/deploymentconfig.go index 25738dc46..d73c489f7 100644 --- a/pkg/reconcilers/deploymentconfig.go +++ b/pkg/reconcilers/deploymentconfig.go @@ -57,6 +57,33 @@ func GenericBackendMutators() []DCMutateFn { } } +func DeploymentConfigEnvMutator(desired, existing *appsv1.DeploymentConfig) (bool, error) { + update := false + if !reflect.DeepEqual(existing.Spec.Template.Spec.Containers[0].Env, desired.Spec.Template.Spec.Containers[0].Env) { + diff := cmp.Diff(existing.Spec.Template.Spec.Containers[0].Env, desired.Spec.Template.Spec.Containers[0].Env) + log.Info(fmt.Sprintf("%s spec.template.spec.containers[0].Env has changed: %s", common.ObjectInfo(desired), diff)) + // Always set env var CONFIG_REDIS_ASYNC to 1 + for envId, envVar := range existing.Spec.Template.Spec.Containers[0].Env { + if envVar.Name == "CONFIG_REDIS_ASYNC" { + if envVar.Value != "1" { + existing.Spec.Template.Spec.Containers[0].Env[envId].Value = "1" + update = true + return update, nil + } + return update, nil + } + } + // Always set env var create CONFIG_REDIS_ASYNC if not present + for envId, envVar := range desired.Spec.Template.Spec.Containers[0].Env { + if envVar.Name == "CONFIG_REDIS_ASYNC" { + existing.Spec.Template.Spec.Containers[0].Env = append(existing.Spec.Template.Spec.Containers[0].Env, desired.Spec.Template.Spec.Containers[0].Env[envId]) + update = true + } + } + } + return update, nil +} + func DeploymentConfigReplicasMutator(desired, existing *appsv1.DeploymentConfig) (bool, error) { update := false