Skip to content

Commit f4a2bfb

Browse files
committed
fix: apache instrumentation with lifecycle
1 parent 0fdf105 commit f4a2bfb

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

pkg/instrumentation/apachehttpd.go

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod
103103
cloneContainer.LivenessProbe = nil
104104
cloneContainer.ReadinessProbe = nil
105105
cloneContainer.StartupProbe = nil
106+
// remove lifecycle, since not supported on init containers
107+
cloneContainer.Lifecycle = nil
106108

107109
pod.Spec.InitContainers = append(pod.Spec.InitContainers, *cloneContainer)
108110

pkg/instrumentation/apachehttpd_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
215215
},
216216
},
217217
},
218-
// === Test Removal of probes =============================
218+
// === Test Removal of probes and lifecycle =============================
219219
{
220220
name: "Probes removed on clone init container",
221221
ApacheHttpd: v1alpha1.ApacheHttpd{Image: "foo/bar:1"},
@@ -226,6 +226,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
226226
ReadinessProbe: &corev1.Probe{},
227227
StartupProbe: &corev1.Probe{},
228228
LivenessProbe: &corev1.Probe{},
229+
Lifecycle: &corev1.Lifecycle{},
229230
},
230231
},
231232
},
@@ -307,6 +308,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
307308
ReadinessProbe: &corev1.Probe{},
308309
StartupProbe: &corev1.Probe{},
309310
LivenessProbe: &corev1.Probe{},
311+
Lifecycle: &corev1.Lifecycle{},
310312
},
311313
},
312314
},

tests/e2e-instrumentation/instrumentation-apache-httpd/01-install-app.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ spec:
2626
allowPrivilegeEscalation: false
2727
capabilities:
2828
drop: ["ALL"]
29+
# following to test lifecycle removal in cloned init container
30+
lifecycle:
31+
postStart:
32+
exec:
33+
command: [ "/bin/sh", "-c", "echo Hello from the postStart handler" ]
2934
ports:
3035
- containerPort: 8080
3136
resources:

0 commit comments

Comments
 (0)