Commit 36105ed
[Backport 7.77.x] fix(cluster-agent): Guard against re-admission for APM auto-instrumentation in image_volume mode (#46819)
Backport 2d33331 from #46743.
___
### What does this PR do?
Avoid double-injection by returning early if the pod already has image_volume mode's init containers.
Init_container mode was already guarded by checking for per-language init containers (e.g. datadog-lib-python-init). This change adds the same style of guard for image_volume mode by checking for the datadog-apm-inject-preload init container.
### Motivation
The webhook may be run twice, but we do not want to inject twice. CSI mode needs a guard in the future as well.
### Describe how you validated your changes
Tests in target_mutator_test.go were added for both re-admission cases: one for init_container mode and one for image_volume mode. The test asserts that the pod is not changed ("mutated") at all in the case that the representative init container(s) are present.
### Additional Notes
Co-authored-by: sabrina.lu <sabrina.lu@datadoghq.com>1 parent 6ca22bc commit 36105ed
File tree
3 files changed
+39
-0
lines changed- pkg/clusteragent/admission/mutate/autoinstrumentation
- releasenotes/notes
3 files changed
+39
-0
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
194 | 201 | | |
195 | 202 | | |
196 | 203 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
145 | 174 | | |
146 | 175 | | |
147 | 176 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments