From 47245111be5ccb83c40add67046bcb41fe3bf75b Mon Sep 17 00:00:00 2001 From: Marcell Sevcsik <31651557+0sewa0@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:59:07 +0100 Subject: [PATCH] Add default oneagent initial retry in case of istio (#2374) --- pkg/api/v1beta1/dynakube/feature_flags.go | 15 +++++++++--- .../v1beta1/dynakube/feature_flags_test.go | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pkg/api/v1beta1/dynakube/feature_flags.go b/pkg/api/v1beta1/dynakube/feature_flags.go index ea897c3f76..143859bdbf 100644 --- a/pkg/api/v1beta1/dynakube/feature_flags.go +++ b/pkg/api/v1beta1/dynakube/feature_flags.go @@ -119,8 +119,9 @@ const ( ) const ( - DefaultMaxFailedCsiMountAttempts = 10 - DefaultMinRequestThresholdMinutes = 15 + DefaultMaxFailedCsiMountAttempts = 10 + DefaultMinRequestThresholdMinutes = 15 + IstioDefaultOneAgentInitialConnectRetry = 6000 ) var ( @@ -309,7 +310,15 @@ func (dk *DynaKube) FeatureLabelVersionDetection() bool { // FeatureAgentInitialConnectRetry is a feature flag to configure startup delay of standalone agents func (dk *DynaKube) FeatureAgentInitialConnectRetry() int { - return dk.getFeatureFlagInt(AnnotationFeatureOneAgentInitialConnectRetry, -1) + defaultValue := -1 + ffValue := dk.getFeatureFlagInt(AnnotationFeatureOneAgentInitialConnectRetry, defaultValue) + + // In case of istio, we want to have a longer initial delay for codemodules to ensure the DT service is created consistently + if ffValue == defaultValue && dk.Spec.EnableIstio { + ffValue = IstioDefaultOneAgentInitialConnectRetry + } + + return ffValue } func (dk *DynaKube) FeatureOneAgentPrivileged() bool { diff --git a/pkg/api/v1beta1/dynakube/feature_flags_test.go b/pkg/api/v1beta1/dynakube/feature_flags_test.go index 49d678318b..aeb790427b 100644 --- a/pkg/api/v1beta1/dynakube/feature_flags_test.go +++ b/pkg/api/v1beta1/dynakube/feature_flags_test.go @@ -319,3 +319,27 @@ func TestInjectionFailurePolicy(t *testing.T) { }) } } + +func TestAgentInitialConnectRetry(t *testing.T) { + t.Run("default => not set", func(t *testing.T) { + dynakube := createDynakubeEmptyDynakube() + + initialRetry := dynakube.FeatureAgentInitialConnectRetry() + require.Equal(t, -1, initialRetry) + }) + t.Run("istio default => set", func(t *testing.T) { + dynakube := createDynakubeEmptyDynakube() + dynakube.Spec.EnableIstio = true + + initialRetry := dynakube.FeatureAgentInitialConnectRetry() + require.Equal(t, IstioDefaultOneAgentInitialConnectRetry, initialRetry) + }) + t.Run("istio default can be overruled", func(t *testing.T) { + dynakube := createDynakubeEmptyDynakube() + dynakube.Spec.EnableIstio = true + dynakube.Annotations[AnnotationFeatureOneAgentInitialConnectRetry] = "5" + + initialRetry := dynakube.FeatureAgentInitialConnectRetry() + require.Equal(t, 5, initialRetry) + }) +}