Skip to content

Commit

Permalink
Add default oneagent initial retry in case of istio (#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
0sewa0 authored Nov 16, 2023
1 parent d8cf86c commit 4724511
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/api/v1beta1/dynakube/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ const (
)

const (
DefaultMaxFailedCsiMountAttempts = 10
DefaultMinRequestThresholdMinutes = 15
DefaultMaxFailedCsiMountAttempts = 10
DefaultMinRequestThresholdMinutes = 15
IstioDefaultOneAgentInitialConnectRetry = 6000
)

var (
Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions pkg/api/v1beta1/dynakube/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit 4724511

Please sign in to comment.