Skip to content

Commit

Permalink
Prevent bad configuration with install error report
Browse files Browse the repository at this point in the history
  • Loading branch information
clamoriniere committed Nov 21, 2024
1 parent 46914e5 commit 03fad8d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
18 changes: 18 additions & 0 deletions charts/datadog/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,24 @@ More information about this change: https://github.com/DataDog/helm-charts/pull/
{{- end }}


{{- if and (ne .Values.targetSystem "linux") (eq (include "should-add-host-path-for-os-release-paths" .) "false") .Values.datadog.sbom.host.enabled }}
#################################################################
#### ERROR: Configuration notice ####
#################################################################
The collection of SBOM host filesystem feature requires to have access on the os-release information from the host.
{{- fail "The collection of SBOM host filesystem feature requires to have access on the os-release information from the host." }}
{{- end }}

{{- if and (ne .Values.targetSystem "linux") (eq (include "should-add-host-path-for-os-release-paths" .) "false") (eq (include "should-enable-system-probe" .) "true") }}
#################################################################
#### ERROR: Configuration notice ####
#################################################################
The current set off options used to install the chart requires the activation of the `system-probe` container.
However, the option 'datadog.disableDefaultOsReleasePaths' set to 'true' is not compatible when `system-probe` container is required.
{{- fail "datadog.disableDefaultOsReleasePaths can't be set to `true` when system-probe is enabled." }}
{{- end }}


{{- $hasContainerIncludeEnv := false }}
{{- range $key := .Values.datadog.env }}
{{- if eq $key.name "DD_CONTAINER_INCLUDE" }}
Expand Down
4 changes: 2 additions & 2 deletions charts/datadog/templates/_daemonset-volumes-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
- hostPath:
path: /sys/fs/cgroup
name: cgroups
{{- if and (not .Values.providers.gke.autopilot) (not .Values.datadog.disableDefaultOsReleasePaths) (or .Values.datadog.systemProbe.osReleasePath .Values.datadog.osReleasePath .Values.datadog.sbom.host.enabled) }}
{{- if and (not .Values.providers.gke.autopilot) (or .Values.datadog.systemProbe.osReleasePath .Values.datadog.osReleasePath .Values.datadog.sbom.host.enabled) }}
- hostPath:
path: {{ .Values.datadog.systemProbe.osReleasePath | default .Values.datadog.osReleasePath }}
name: os-release-file
{{- end }}
{{- if or (and (eq (include "should-enable-system-probe" .) "true") (and .Values.datadog.systemProbe.enableDefaultOsReleasePaths (not .Values.datadog.disableDefaultOsReleasePaths))) .Values.datadog.sbom.host.enabled }}
{{- if and ((eq (include "should-add-host-path-for-os-release-path" .) "true") (or (eq (include "should-enable-system-probe" .) "true") .Values.datadog.sbom.host.enabled) }}
- hostPath:
path: /etc/redhat-release
name: etc-redhat-release
Expand Down
14 changes: 14 additions & 0 deletions charts/datadog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1002,3 +1002,17 @@ Create RBACs for custom resources
{{- end -}}
{{- end -}}
{{- end -}}


{{/*
Returns true if Host paths for default OS Release Paths need to be added to the volumes.
*/}}
{{- define "should-add-host-path-for-os-release-paths" -}}
{{- if ne .Values.targetSystem "linux" -}}
false
{{- else if (and .Values.datadog.systemProbe.enableDefaultOsReleasePaths (not .Values.datadog.disableDefaultOsReleasePaths)) -}}
true
{{- else -}}
false
{{- end -}}
{{- end -}}

0 comments on commit 03fad8d

Please sign in to comment.