-
Notifications
You must be signed in to change notification settings - Fork 0
feat(helm): observability support (ArcadeDB 26.7.1, #4463) #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
14f43ad
5a22573
cd4658a
14392e8
63ddf32
41205f8
b16f1b2
6ea4556
e75014e
9e17bbb
5b5308e
9035962
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,11 @@ Create a comma separated list of plugins to be enabled in arcadedb | |
| {{- $params = append $params (printf "-Darcadedb.redis.port=%d" (int $config.port)) -}} | ||
| {{- else if eq $plugin "prometheus" -}} | ||
| {{- $plugins = append $plugins "Prometheus:com.arcadedb.metrics.prometheus.PrometheusMetricsPlugin" -}} | ||
| {{- with $.Values.arcadedb.plugins.prometheus -}} | ||
| {{- if hasKey . "requireAuthentication" -}} | ||
| {{- $params = append $params (printf "-Darcadedb.serverMetrics.prometheus.requireAuthentication=%v" .requireAuthentication) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- else -}} | ||
| {{- $plugins = append $plugins (printf "%s:%s" $plugin $config.class) -}} | ||
| {{- end -}} | ||
|
|
@@ -170,3 +175,71 @@ Create service configuration for the enabled plugins | |
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Observability -D JVM args (logging, OTLP metrics, tracing, readiness). | ||
| All opt-in; emits nothing when defaults are unchanged. | ||
| */}} | ||
| {{- define "arcadedb.observability.args" -}} | ||
| {{- $o := .Values.observability | default dict -}} | ||
| {{- $logging := $o.logging | default dict -}} | ||
| {{- $otlp := (($o.metrics | default dict).otlp) | default dict -}} | ||
| {{- $tracing := $o.tracing | default dict -}} | ||
| {{- $health := $o.health | default dict -}} | ||
| {{- if eq $logging.format "json" }} | ||
| - -Darcadedb.server.logFormat=json | ||
| {{- end }} | ||
| {{- if $logging.includeTrace }} | ||
| - -Darcadedb.server.logIncludeTrace=true | ||
| {{- end }} | ||
| {{- if $otlp.enabled }} | ||
| - -Darcadedb.serverMetrics.otlp.enabled=true | ||
| - -Darcadedb.serverMetrics.otlp.endpoint={{ $otlp.endpoint }} | ||
| {{- end }} | ||
| {{- if $tracing.enabled }} | ||
| - -Darcadedb.serverMetrics.tracing.enabled=true | ||
| - -Darcadedb.serverMetrics.tracing.endpoint={{ $tracing.endpoint }} | ||
| - -Darcadedb.serverMetrics.tracing.samplingRate={{ $tracing.samplingRate }} | ||
| {{- end }} | ||
| {{- if $health.readinessRequiresHA }} | ||
| - -Darcadedb.server.readinessRequiresHA=true | ||
| {{- end }} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Guard: scrape discovery (ServiceMonitor or pod annotations) needs the | ||
| prometheus plugin so /prometheus is actually served. | ||
| */}} | ||
| {{- define "arcadedb.observability.validate" -}} | ||
| {{- $p := (((.Values.observability | default dict).metrics | default dict).prometheus) | default dict -}} | ||
| {{- $serviceMonitor := $p.serviceMonitor | default dict -}} | ||
| {{- $podAnnotations := $p.podAnnotations | default dict -}} | ||
| {{- if or $serviceMonitor.enabled $podAnnotations.enabled -}} | ||
| {{- $promEnabled := false -}} | ||
| {{- with .Values.arcadedb.plugins.prometheus -}} | ||
| {{- if .enabled -}}{{- $promEnabled = true -}}{{- end -}} | ||
| {{- end -}} | ||
| {{- if not $promEnabled -}} | ||
| {{- fail "observability.metrics.prometheus serviceMonitor/podAnnotations require arcadedb.plugins.prometheus.enabled=true (the /prometheus endpoint must be served)" -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
Comment on lines
+213
to
+226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation helper
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 9e17bbb — |
||
|
|
||
| {{/* | ||
| Merge user-supplied podAnnotations with computed prometheus.io/* scrape | ||
| annotations. Returns YAML (possibly empty). | ||
| */}} | ||
| {{- define "arcadedb.podAnnotations" -}} | ||
| {{- $annotations := deepCopy (default dict .Values.podAnnotations) -}} | ||
| {{- $pa := (((((.Values.observability | default dict).metrics | default dict).prometheus) | default dict).podAnnotations) | default dict -}} | ||
| {{- if $pa.enabled -}} | ||
| {{- $port := int .Values.service.http.port -}} | ||
| {{- if $pa.port -}}{{- $port = int $pa.port -}}{{- end -}} | ||
| {{- $_ := set $annotations "prometheus.io/scrape" "true" -}} | ||
| {{- $_ := set $annotations "prometheus.io/port" (printf "%d" $port) -}} | ||
| {{- $_ := set $annotations "prometheus.io/path" (default "/prometheus" $pa.path) -}} | ||
| {{- end -}} | ||
| {{- if $annotations -}} | ||
| {{- toYaml $annotations -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
Comment on lines
+232
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The helper
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 9e17bbb — |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| {{- $sm := (((((.Values.observability | default dict).metrics | default dict).prometheus) | default dict).serviceMonitor) | default dict -}} | ||
| {{- if $sm.enabled }} | ||
| {{- include "arcadedb.observability.validate" . -}} | ||
| {{- $basicAuth := $sm.basicAuth | default dict -}} | ||
| {{- if and $basicAuth.enabled (not $basicAuth.secretName) -}} | ||
| {{- fail "serviceMonitor.basicAuth.enabled requires basicAuth.secretName (a secret with username + password keys)" -}} | ||
| {{- end -}} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "arcadedb.fullname" . }} | ||
| labels: | ||
| {{- include "arcadedb.labels" . | nindent 4 }} | ||
| {{- with $sm.labels }} | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with $sm.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| {{- include "arcadedb.selectorLabels" . | nindent 6 }} | ||
| app.kubernetes.io/component: http | ||
| endpoints: | ||
| - port: http | ||
| path: {{ $sm.path }} | ||
| interval: {{ $sm.interval }} | ||
| {{- with $sm.scrapeTimeout }} | ||
| scrapeTimeout: {{ . }} | ||
| {{- end }} | ||
| {{- if $basicAuth.enabled }} | ||
| basicAuth: | ||
| username: | ||
| name: {{ $basicAuth.secretName }} | ||
| key: {{ $basicAuth.usernameKey }} | ||
| password: | ||
| name: {{ $basicAuth.secretName }} | ||
| key: {{ $basicAuth.passwordKey }} | ||
| {{- end }} | ||
| {{- with $sm.relabelings }} | ||
| relabelings: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with $sm.metricRelabelings }} | ||
| metricRelabelings: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper
arcadedb.observability.argsdirectly accesses nested keys under.Values.observability(such as.Values.observability.logging.formatand.Values.observability.metrics.otlp.enabled) without checking if the parent keys exist. If a user provides a custom values file that partially overrides or completely omits theobservabilitysection, Helm will throw a nil pointer evaluation error (e.g.,nil pointer evaluating interface {}). Usingdefault dictto safely navigate these nested maps prevents rendering crashes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified this empirically before applying. The stated trigger — partially overriding or omitting the
observabilitysection — does not panic: Helm coalesces user values over the chart'svalues.yamldefaults, so omitted/partially-set keys retain their defaults (helm template -fwith onlyobservability.metrics.otlp.enabled: truerenders fine, exit 0; the unit suite also sets partial observability keys and passes).The real failure mode is explicitly nulling a map, e.g.
--set observability=nullor--set observability.logging=null, which does dereference nil. That's a genuine crash, so I've applied nil-safe navigation (| default dict) to this helper and the other three sites, plus regression tests covering the explicit-null case.Fixed in 9e17bbb.