Skip to content

Commit

Permalink
fix: apache instrumentation with lifecycle (#3548)
Browse files Browse the repository at this point in the history
* fix(doc): instrumentation documentation

* fix: apache instrumentation with lifecycle
  • Loading branch information
L3o-pold authored Dec 17, 2024
1 parent 441d61b commit 712cfe3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/fix_apache-instrumentation-with-lifecycle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: auto-instrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Apache instrumentation sidecar fails to start if target container define lifecycle

# One or more tracking issues related to the change
issues: [3547]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions pkg/instrumentation/apachehttpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod
cloneContainer.LivenessProbe = nil
cloneContainer.ReadinessProbe = nil
cloneContainer.StartupProbe = nil
// remove lifecycle, since not supported on init containers
cloneContainer.Lifecycle = nil

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

Expand Down
4 changes: 3 additions & 1 deletion pkg/instrumentation/apachehttpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
},
},
},
// === Test Removal of probes =============================
// === Test Removal of probes and lifecycle =============================
{
name: "Probes removed on clone init container",
ApacheHttpd: v1alpha1.ApacheHttpd{Image: "foo/bar:1"},
Expand All @@ -226,6 +226,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
ReadinessProbe: &corev1.Probe{},
StartupProbe: &corev1.Probe{},
LivenessProbe: &corev1.Probe{},
Lifecycle: &corev1.Lifecycle{},
},
},
},
Expand Down Expand Up @@ -307,6 +308,7 @@ func TestInjectApacheHttpdagent(t *testing.T) {
ReadinessProbe: &corev1.Probe{},
StartupProbe: &corev1.Probe{},
LivenessProbe: &corev1.Probe{},
Lifecycle: &corev1.Lifecycle{},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ spec:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
# following to test lifecycle removal in cloned init container
lifecycle:
postStart:
exec:
command: [ "/bin/sh", "-c", "echo Hello from the postStart handler" ]
ports:
- containerPort: 8080
resources:
Expand Down

0 comments on commit 712cfe3

Please sign in to comment.