Skip to content

Commit

Permalink
[cws-instrumentation] Ignore miss-configurations when cws instrumenta…
Browse files Browse the repository at this point in the history
…tion is disabled (#31472)
  • Loading branch information
Gui774ume authored Nov 26, 2024
1 parent 3caec42 commit 00429a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
/pkg/clusteragent/autoscaling/ @DataDog/container-integrations
/pkg/clusteragent/admission/mutate/autoscaling @DataDog/container-integrations
/pkg/clusteragent/admission/mutate/autoinstrumentation/ @DataDog/container-platform @DataDog/injection-platform
/pkg/clusteragent/admission/mutate/cwsinstrumentation @Datadog/agent-security
/pkg/clusteragent/orchestrator/ @DataDog/container-app
/pkg/clusteragent/telemetry/ @DataDog/apm-trace-storage
/pkg/collector/ @DataDog/agent-metrics-logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/clusteragent/admission/mutate/cwsinstrumentation"
"github.com/DataDog/datadog-agent/pkg/clusteragent/admission/mutate/tagsfromlabels"
"github.com/DataDog/datadog-agent/pkg/clusteragent/autoscaling/workload"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/util/log"
)

Expand Down Expand Up @@ -127,11 +128,14 @@ func (c *controllerBase) generateWebhooks(wmeta workloadmeta.Component, pa workl
log.Errorf("failed to register APM Instrumentation webhook: %v", err)
}

cws, err := cwsinstrumentation.NewCWSInstrumentation(wmeta, datadogConfig)
if err == nil {
webhooks = append(webhooks, cws.WebhookForPods(), cws.WebhookForCommands())
} else {
log.Errorf("failed to register CWS Instrumentation webhook: %v", err)
isCWSInstrumentationEnabled := pkgconfigsetup.Datadog().GetBool("admission_controller.cws_instrumentation.enabled")
if isCWSInstrumentationEnabled {
cws, err := cwsinstrumentation.NewCWSInstrumentation(wmeta, datadogConfig)
if err == nil {
webhooks = append(webhooks, cws.WebhookForPods(), cws.WebhookForCommands())
} else {
log.Errorf("failed to register CWS Instrumentation webhook: %v", err)
}
}
}

Expand Down

0 comments on commit 00429a1

Please sign in to comment.