You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ssi): merge target and namespace implementations (#42068)
### What does this PR do?
When we introduced targets, we created a separate code path to handle the target based configuration. However, the namespace based configuration can also be represented and supported by the target implementation. This commit merges the two implementations.
When I merged these in code, I found bugs in the target implementation surrounding [Local SDK Injection](https://docs.datadoghq.com/tracing/guide/local_sdk_injection/) and how it was handled with targets defined. This change fixes those bugs to match the expectations around enabledNamespaces.
### Motivation
We want to reduce the complexity of the auto instrumentation webhook. There is no need to have two implementations to support our customer facing configuration options and as shown with this change, two implementations open up more chances for bugs.
See [SSI Kubernetes | Platform Stability](https://docs.google.com/document/d/1NqrPEUn3RfcdS_hQUQB-pJFJN9N-x5I202CB7s7CnwQ/edit?usp=sharing) for more details on all changes related to cleanup.
### Describe how you validated your changes
I tested this change heavily using [injector-dev](https://github.com/DataDog/injector-dev). For each scenario listed, I ran with and without the `--build` flag to use the latest agent release vs this branch to ensure there was a seamless migration path.
<details>
<summary>Broken annotation based injection with target list</summary>
This should have injection but it does not currently:
```yaml
helm:
apps:
- name: annotation-example
namespace: application
values:
env:
- name: DD_TRACE_DEBUG
value: "true"
- name: DD_APM_INSTRUMENTATION_DEBUG
value: "true"
image:
repository: registry.ddbuild.io/ci/injector-dev/python
tag: 2cd78ded
podLabels:
admission.datadoghq.com/enabled: "true"
tags.datadoghq.com/env: local
podAnnotations:
admission.datadoghq.com/python-lib.version: "v3"
service:
port: "8080"
versions:
agent: 7.71.1
cluster_agent:
version: 7.71.1
build: {}
injector: 0.48.0
config:
datadog:
apm:
instrumentation:
enabled: false
targets:
- name: python
podSelector:
matchLabels:
language: python
ddTraceVersions:
python: "3"
```
</details>
<details>
<summary>Annotation based injection</summary>
We expect injection:
```yaml
helm:
apps:
- name: annotation-example
namespace: application
values:
env:
- name: DD_TRACE_DEBUG
value: "true"
- name: DD_APM_INSTRUMENTATION_DEBUG
value: "true"
image:
repository: registry.ddbuild.io/ci/injector-dev/python
tag: 2cd78ded
podLabels:
admission.datadoghq.com/enabled: "true"
tags.datadoghq.com/env: local
podAnnotations:
admission.datadoghq.com/python-lib.version: "v3"
service:
port: "8080"
versions:
agent: 7.71.1
cluster_agent:
version: 7.71.1
build: {}
injector: 0.48.0
config:
datadog:
apm:
instrumentation:
enabled: false
```
</details>
<details>
<summary>Namespace based selection</summary>
We expect injection:
```yaml
helm:
apps:
- name: namespace-selection-example
namespace: application
values:
env:
- name: DD_TRACE_DEBUG
value: "true"
- name: DD_APM_INSTRUMENTATION_DEBUG
value: "true"
image:
repository: registry.ddbuild.io/ci/injector-dev/python
tag: 2cd78ded
podLabels:
tags.datadoghq.com/env: local
service:
port: "8080"
versions:
agent: 7.71.1
cluster_agent:
version: 7.71.1
build: {}
injector: 0.48.0
config:
datadog:
apm:
instrumentation:
enabled: true
enabledNamespaces:
- "application"
libVersions:
python: "3"
```
</details>
<details>
<summary>Workload selection</summary>
We expect injection:
```yaml
helm:
apps:
- name: workload-selection-example
namespace: application
values:
env:
- name: DD_TRACE_DEBUG
value: "true"
- name: DD_APM_INSTRUMENTATION_DEBUG
value: "true"
image:
repository: registry.ddbuild.io/ci/injector-dev/python
tag: 2cd78ded
podLabels:
language: python
tags.datadoghq.com/env: local
service:
port: "8080"
versions:
agent: 7.71.1
cluster_agent:
version: 7.71.1
build: {}
injector: 0.48.0
config:
datadog:
apm:
instrumentation:
enabled: true
targets:
- name: python
podSelector:
matchLabels:
language: python
ddTraceVersions:
python: "3"
```
</details>
<details>
<summary>Instrumentation disabled</summary>
We expect no injection to occur:
```yaml
helm:
apps:
- name: disabled-example
namespace: application
values:
env:
- name: DD_TRACE_DEBUG
value: "true"
- name: DD_APM_INSTRUMENTATION_DEBUG
value: "true"
image:
repository: registry.ddbuild.io/ci/injector-dev/python
tag: 2cd78ded
podLabels:
tags.datadoghq.com/env: local
service:
port: "8080"
versions:
agent: 7.71.1
cluster_agent:
version: 7.71.1
build: {}
injector: 0.48.0
config:
datadog:
apm:
instrumentation:
enabled: false
```
</details>
### Additional Notes
This change opted to not change the behavior of any tests and to keep test changes minimal. A follow up PR will rewrite some of these tests to test the webhook behavior more directly.
Co-authored-by: stanistan <[email protected]>
Co-authored-by: mark.spicer <[email protected]>
0 commit comments