From bbe80bc58f146e57d4be3dbf09ba00eb23073148 Mon Sep 17 00:00:00 2001 From: Liliya Belaus <59583867+liliyadd@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:53:45 -0500 Subject: [PATCH] Fix nil bug when using sync.once (#23002) [APM Onboarding] SSI bug fix for 7.52.0 --- pkg/clusteragent/admission/mutate/auto_instrumentation.go | 2 +- .../admission/mutate/auto_instrumentation_test.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/clusteragent/admission/mutate/auto_instrumentation.go b/pkg/clusteragent/admission/mutate/auto_instrumentation.go index f621346b692a7..daee6472ef5c0 100644 --- a/pkg/clusteragent/admission/mutate/auto_instrumentation.go +++ b/pkg/clusteragent/admission/mutate/auto_instrumentation.go @@ -80,7 +80,7 @@ type language string type pinnedLibraries struct { libraries []libInfo - once *sync.Once + once sync.Once } const ( diff --git a/pkg/clusteragent/admission/mutate/auto_instrumentation_test.go b/pkg/clusteragent/admission/mutate/auto_instrumentation_test.go index d862f54393174..2e1f72c09e284 100644 --- a/pkg/clusteragent/admission/mutate/auto_instrumentation_test.go +++ b/pkg/clusteragent/admission/mutate/auto_instrumentation_test.go @@ -12,7 +12,6 @@ import ( "os" "strconv" "strings" - "sync" "testing" "time" @@ -575,8 +574,7 @@ func TestExtractLibInfo(t *testing.T) { } // reset pinned libraries between test runs - pinnedLibs.once = new(sync.Once) - pinnedLibs.libraries = []libInfo{} + pinnedLibs = &pinnedLibraries{} apmInstrumentation, err := newAPMInstrumentationWebhook() require.NoError(t, err) @@ -1848,8 +1846,7 @@ func TestInjectAutoInstrumentation(t *testing.T) { fakeStoreWithDeployment(t, tt.langDetectionDeployments) // reset pinned libraries between test runs - pinnedLibs.once = new(sync.Once) - pinnedLibs.libraries = []libInfo{} + pinnedLibs = &pinnedLibraries{} apmInstrumentation, err := newAPMInstrumentationWebhook() require.NoError(t, err)