From ca4a70b7ef334f14b9be6961b9f5d3d3716cca33 Mon Sep 17 00:00:00 2001 From: Wenying Dong Date: Fri, 20 Jan 2023 12:39:41 +0800 Subject: [PATCH] Modify the message length limitation in ANP Condition (#4574) Modify the max length of Message field in ANP Condtion to 256 Signed-off-by: wenyingd --- pkg/controller/networkpolicy/status_controller.go | 2 +- .../networkpolicy/status_controller_test.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/controller/networkpolicy/status_controller.go b/pkg/controller/networkpolicy/status_controller.go index 613f57b5f82..5c654915482 100644 --- a/pkg/controller/networkpolicy/status_controller.go +++ b/pkg/controller/networkpolicy/status_controller.go @@ -51,7 +51,7 @@ var ( // maxConditionMessageLength defines the max length of the message field in one Condition. If the actual message // length is over size, truncate the string and use "..." in the end. // Use a variable for test. - maxConditionMessageLength = 100 + maxConditionMessageLength = 256 ) // StatusController is responsible for synchronizing the status of Antrea ClusterNetworkPolicy and Antrea NetworkPolicy. diff --git a/pkg/controller/networkpolicy/status_controller_test.go b/pkg/controller/networkpolicy/status_controller_test.go index def2beb3676..2b4f549e96b 100644 --- a/pkg/controller/networkpolicy/status_controller_test.go +++ b/pkg/controller/networkpolicy/status_controller_test.go @@ -274,10 +274,14 @@ func TestCreateAntreaNetworkPolicy(t *testing.T) { }, }, } - maxConditionMessageLength = 45 - defer func() { - maxConditionMessageLength = 100 - }() + updateMaxConditionMessageLength := func() func() { + originalMaxConditionMessageLength := maxConditionMessageLength + maxConditionMessageLength = 45 + return func() { + maxConditionMessageLength = originalMaxConditionMessageLength + } + } + defer updateMaxConditionMessageLength()() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { var initObjects []runtime.Object