Skip to content

Commit d97bf4b

Browse files
committed
Fix
Signed-off-by: Pavol Loffay <[email protected]>
1 parent e2f724f commit d97bf4b

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

pkg/instrumentation/javaagent.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
javaInstrMountPath = "/otel-auto-instrumentation-java"
3131
)
3232

33-
func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.Pod, error) {
33+
func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) corev1.Pod {
3434
// caller checks if there is at least one container.
3535
container := &pod.Spec.Containers[index]
3636

@@ -96,5 +96,5 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.
9696
}
9797

9898
}
99-
return pod, nil
99+
return pod
100100
}

pkg/instrumentation/javaagent_test.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func TestInjectJavaagent(t *testing.T) {
2929
v1alpha1.Java
3030
pod corev1.Pod
3131
expected corev1.Pod
32-
err error
3332
}{
3433
{
3534
name: "JAVA_TOOL_OPTIONS not defined",
@@ -82,7 +81,6 @@ func TestInjectJavaagent(t *testing.T) {
8281
},
8382
},
8483
},
85-
err: nil,
8684
},
8785
{
8886
name: "add extensions to JAVA_TOOL_OPTIONS",
@@ -156,7 +154,6 @@ func TestInjectJavaagent(t *testing.T) {
156154
},
157155
},
158156
},
159-
err: nil,
160157
},
161158
{
162159
name: "JAVA_TOOL_OPTIONS defined",
@@ -221,7 +218,6 @@ func TestInjectJavaagent(t *testing.T) {
221218
},
222219
},
223220
},
224-
err: nil,
225221
},
226222
{
227223
name: "JAVA_TOOL_OPTIONS defined as ValueFrom",
@@ -291,9 +287,8 @@ func TestInjectJavaagent(t *testing.T) {
291287

292288
for _, test := range tests {
293289
t.Run(test.name, func(t *testing.T) {
294-
pod, err := injectJavaagent(test.Java, test.pod, 0)
290+
pod := injectJavaagent(test.Java, test.pod, 0)
295291
assert.Equal(t, test.expected, pod)
296-
assert.Equal(t, test.err, err)
297292
})
298293
}
299294
}

pkg/instrumentation/sdk.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations
5959
}
6060
if insts.Java.Instrumentation != nil {
6161
otelinst := *insts.Java.Instrumentation
62-
var err error
6362
i.logger.V(1).Info("injecting Java instrumentation into pod", "otelinst-namespace", otelinst.Namespace, "otelinst-name", otelinst.Name)
6463

6564
if len(insts.Java.Containers) == 0 {
@@ -68,14 +67,10 @@ func (i *sdkInjector) inject(ctx context.Context, insts languageInstrumentations
6867

6968
for _, container := range insts.Java.Containers {
7069
index := getContainerIndex(container, pod)
71-
pod, err = injectJavaagent(otelinst.Spec.Java, pod, index)
72-
if err != nil {
73-
i.logger.Info("Skipping javaagent injection", "reason", err.Error(), "container", pod.Spec.Containers[index].Name)
74-
} else {
75-
pod = i.injectCommonEnvVar(otelinst, pod, index)
76-
pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index, index)
77-
pod = i.setInitContainerSecurityContext(pod, pod.Spec.Containers[index].SecurityContext, javaInitContainerName)
78-
}
70+
pod = injectJavaagent(otelinst.Spec.Java, pod, index)
71+
pod = i.injectCommonEnvVar(otelinst, pod, index)
72+
pod = i.injectCommonSDKConfig(ctx, otelinst, ns, pod, index, index)
73+
pod = i.setInitContainerSecurityContext(pod, pod.Spec.Containers[index].SecurityContext, javaInitContainerName)
7974
}
8075
}
8176
if insts.NodeJS.Instrumentation != nil {

0 commit comments

Comments
 (0)