From b3f3fc96accce8e84725d11da61efe265e03eba9 Mon Sep 17 00:00:00 2001 From: Austin Cunningham Date: Thu, 17 Aug 2023 14:09:20 +0100 Subject: [PATCH] THREESCALE-7864 set async by default on backend work --- pkg/3scale/amp/component/backend.go | 1 + pkg/reconcilers/deploymentconfig.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/3scale/amp/component/backend.go b/pkg/3scale/amp/component/backend.go index 8e14eb209..dafc32c10 100644 --- a/pkg/3scale/amp/component/backend.go +++ b/pkg/3scale/amp/component/backend.go @@ -393,6 +393,7 @@ func (backend *Backend) buildBackendWorkerEnv() []v1.EnvVar { result := []v1.EnvVar{} result = append(result, backend.buildBackendCommonEnv()...) result = append(result, + helper.EnvVarFromValue("CONFIG_REDIS_ASYNC", "1"), helper.EnvVarFromSecret("CONFIG_EVENTS_HOOK", "system-events-hook", "URL"), helper.EnvVarFromSecret("CONFIG_EVENTS_HOOK_SHARED_SECRET", "system-events-hook", "PASSWORD"), ) diff --git a/pkg/reconcilers/deploymentconfig.go b/pkg/reconcilers/deploymentconfig.go index 25738dc46..58fceb079 100644 --- a/pkg/reconcilers/deploymentconfig.go +++ b/pkg/reconcilers/deploymentconfig.go @@ -10,6 +10,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/3scale/3scale-operator/pkg/3scale/amp/component" "github.com/3scale/3scale-operator/pkg/common" "github.com/3scale/3scale-operator/pkg/helper" ) @@ -54,9 +55,23 @@ func GenericBackendMutators() []DCMutateFn { DeploymentConfigPriorityClassMutator, DeploymentConfigTopologySpreadConstraintsMutator, DeploymentConfigPodTemplateAnnotationsMutator, + DeploymentConfigEnvMutator, } } +func DeploymentConfigEnvMutator(desired, existing *appsv1.DeploymentConfig) (bool, error) { + update := false + if desired.Name == component.BackendWorkerName { + 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)) + existing.Spec.Template.Spec.Containers[0].Env = desired.Spec.Template.Spec.Containers[0].Env + update = true + } + } + return update, nil +} + func DeploymentConfigReplicasMutator(desired, existing *appsv1.DeploymentConfig) (bool, error) { update := false