Skip to content

Commit

Permalink
fix for #2366 (#2385)
Browse files Browse the repository at this point in the history
* fix for #2366

* added cloggen

* typo

* typo

* e2e test for lifecycle removal from init container

* e2e test for lifecycle removal in init container
  • Loading branch information
chrlic authored Nov 27, 2023
1 parent 363f4db commit 0760504
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/issue-2366-fix.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. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: lifecycle spec removed from cloned initContainer

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

# (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/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export %[4]s=$( { nginx -v ; } 2>&1 ) && echo ${%[4]s##*/} > %[3]s/version.txt
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/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestInjectNginxSDK(t *testing.T) {
},
},
}},
// === Test Removal of probes =============================
// === Test Removal of probes and lifecycle =============================
{
name: "Probes removed on clone init container",
Nginx: v1alpha1.Nginx{
Expand All @@ -267,6 +267,7 @@ func TestInjectNginxSDK(t *testing.T) {
ReadinessProbe: &corev1.Probe{},
StartupProbe: &corev1.Probe{},
LivenessProbe: &corev1.Probe{},
Lifecycle: &corev1.Lifecycle{},
},
},
},
Expand Down Expand Up @@ -351,6 +352,7 @@ func TestInjectNginxSDK(t *testing.T) {
ReadinessProbe: &corev1.Probe{},
StartupProbe: &corev1.Probe{},
LivenessProbe: &corev1.Probe{},
Lifecycle: &corev1.Lifecycle{},
Env: []corev1.EnvVar{
{
Name: "LD_LIBRARY_PATH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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: 8765
env:
Expand Down

0 comments on commit 0760504

Please sign in to comment.