From 977adf06b27bbd4dc6ea40698adfbb9f4c35f3d7 Mon Sep 17 00:00:00 2001 From: yangyang Date: Sun, 8 Oct 2023 14:42:14 +0800 Subject: [PATCH 1/3] fix envoy-max-heapsize not set Signed-off-by: yangyang --- internal/provisioner/controller/gateway.go | 4 ++++ internal/provisioner/model/model.go | 11 ++++++----- .../provisioner/objects/dataplane/dataplane_test.go | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 0fd328566ad..baf1b39ddf3 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -361,6 +361,10 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct contourModel.Spec.EnvoyBaseID = envoyParams.BaseID } + if envoyParams.OverloadMaxHeapSize > 0 { + contourModel.Spec.EnvoyMaxHeapSizeBytes = envoyParams.OverloadMaxHeapSize + } + } } diff --git a/internal/provisioner/model/model.go b/internal/provisioner/model/model.go index 0c925ecc1f9..cdb9d149297 100644 --- a/internal/provisioner/model/model.go +++ b/internal/provisioner/model/model.go @@ -38,11 +38,12 @@ func Default(namespace, name string) *Contour { Name: name, }, Spec: ContourSpec{ - ContourReplicas: 2, - EnvoyWorkloadType: WorkloadTypeDaemonSet, - EnvoyReplicas: 2, // ignored if not provisioning Envoy as a deployment. - EnvoyLogLevel: contourv1alpha1.InfoLog, - EnvoyBaseID: 0, + ContourReplicas: 2, + EnvoyWorkloadType: WorkloadTypeDaemonSet, + EnvoyReplicas: 2, // ignored if not provisioning Envoy as a deployment. + EnvoyLogLevel: contourv1alpha1.InfoLog, + EnvoyBaseID: 0, + EnvoyMaxHeapSizeBytes: 0, NetworkPublishing: NetworkPublishing{ Envoy: EnvoyNetworkPublishing{ Type: LoadBalancerServicePublishingType, diff --git a/internal/provisioner/objects/dataplane/dataplane_test.go b/internal/provisioner/objects/dataplane/dataplane_test.go index da5449b7bbf..c6918500d5e 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -290,6 +290,7 @@ func TestDesiredDaemonSet(t *testing.T) { testEnvoyImage := "docker.io/envoyproxy/envoy:test" testLogLevelArg := "--log-level debug" testBaseIDArg := "--base-id 1" + testEnvoyMaxHeapSize := "--overload-max-heap=8000000000" resQutoa := corev1.ResourceRequirements{ Limits: corev1.ResourceList{ @@ -315,6 +316,8 @@ func TestDesiredDaemonSet(t *testing.T) { // Change the Envoy base id to test --base-id 1 cntr.Spec.EnvoyBaseID = 1 + cntr.Spec.EnvoyMaxHeapSizeBytes = 8000000000 + ds := DesiredDaemonSet(cntr, testContourImage, testEnvoyImage) container := checkDaemonSetHasContainer(t, ds, EnvoyContainerName, true) checkContainerHasArg(t, container, testLogLevelArg) @@ -330,6 +333,8 @@ func TestDesiredDaemonSet(t *testing.T) { checkContainerHaveResourceRequirements(t, container) checkContainerHasImage(t, container, testContourImage) + checkContainerHasArg(t, container, testEnvoyMaxHeapSize) + checkDaemonSetHasEnvVar(t, ds, EnvoyContainerName, envoyNsEnvVar) checkDaemonSetHasEnvVar(t, ds, EnvoyContainerName, envoyPodEnvVar) checkDaemonSetHasEnvVar(t, ds, envoyInitContainerName, envoyNsEnvVar) From 9d134ce8aa07bc09e70c982612476a6f2672f088 Mon Sep 17 00:00:00 2001 From: yangyang Date: Tue, 10 Oct 2023 11:12:42 +0800 Subject: [PATCH 2/3] add ut Signed-off-by: yangyang --- .../provisioner/controller/gateway_test.go | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/internal/provisioner/controller/gateway_test.go b/internal/provisioner/controller/gateway_test.go index d3498e0183f..b498c9e72e8 100644 --- a/internal/provisioner/controller/gateway_test.go +++ b/internal/provisioner/controller/gateway_test.go @@ -1110,7 +1110,8 @@ func TestGatewayReconcile(t *testing.T) { }, Spec: contourv1alpha1.ContourDeploymentSpec{ Envoy: &contourv1alpha1.EnvoySettings{ - BaseID: 1, + BaseID: 1, + OverloadMaxHeapSize: 10000000, }, }, }, @@ -1127,6 +1128,56 @@ func TestGatewayReconcile(t *testing.T) { }, }, + "If ContourDeployment.Spec.Envoy.OverloadMaxHeapSize is specified, the envoy-initconfig container's arguments contain --overload-max-heap": { + gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), + gatewayClassParams: &contourv1alpha1.ContourDeployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "projectcontour", + Name: "gatewayclass-1-params", + }, + Spec: contourv1alpha1.ContourDeploymentSpec{ + Envoy: &contourv1alpha1.EnvoySettings{ + OverloadMaxHeapSize: 10000000, + }, + }, + }, + gateway: makeGateway(), + assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) { + ds := &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + require.NoError(t, r.client.Get(context.Background(), keyFor(ds), ds)) + assert.Contains(t, ds.Spec.Template.Spec.InitContainers[0].Args, "--overload-max-heap=10000000") + }, + }, + + "If ContourDeployment.Spec.Envoy.OverloadMaxHeapSize is not specified, the envoy-initconfig container's arguments contain --overload-max-heap=0": { + gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), + gatewayClassParams: &contourv1alpha1.ContourDeployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "projectcontour", + Name: "gatewayclass-1-params", + }, + Spec: contourv1alpha1.ContourDeploymentSpec{ + Envoy: &contourv1alpha1.EnvoySettings{}, + }, + }, + gateway: makeGateway(), + assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) { + ds := &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + require.NoError(t, r.client.Get(context.Background(), keyFor(ds), ds)) + assert.Contains(t, ds.Spec.Template.Spec.InitContainers[0].Args, "--overload-max-heap=0") + }, + }, + "If ContourDeployment.Spec.Contour.PodAnnotations is specified, the Contour pods' have annotations for prometheus & user-defined": { gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), gatewayClassParams: &contourv1alpha1.ContourDeployment{ From daf0ee2d8fba0d3d2e9c45664e6064fa8478f6fc Mon Sep 17 00:00:00 2001 From: yangyang Date: Wed, 11 Oct 2023 16:14:19 +0800 Subject: [PATCH 3/3] update ut Signed-off-by: yangyang --- internal/provisioner/controller/gateway_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/provisioner/controller/gateway_test.go b/internal/provisioner/controller/gateway_test.go index b498c9e72e8..49230049891 100644 --- a/internal/provisioner/controller/gateway_test.go +++ b/internal/provisioner/controller/gateway_test.go @@ -1110,8 +1110,7 @@ func TestGatewayReconcile(t *testing.T) { }, Spec: contourv1alpha1.ContourDeploymentSpec{ Envoy: &contourv1alpha1.EnvoySettings{ - BaseID: 1, - OverloadMaxHeapSize: 10000000, + BaseID: 1, }, }, },