Skip to content

HYPERFLEET-1363 - feat: add Grafana dashboard provisioning to Helm chart - #326

Open
Ruclo wants to merge 1 commit into
openshift-hyperfleet:mainfrom
Ruclo:HYPERFLEET-1363
Open

HYPERFLEET-1363 - feat: add Grafana dashboard provisioning to Helm chart#326
Ruclo wants to merge 1 commit into
openshift-hyperfleet:mainfrom
Ruclo:HYPERFLEET-1363

Conversation

@Ruclo

@Ruclo Ruclo commented Aug 5, 2026

Copy link
Copy Markdown

Why

Part of HYPERFLEET-1363 — unify observability values under monitoring: across all HyperFleet component charts and consolidate dashboard provisioning.

Note: This PR moves serviceMonitor and tracing under monitoring:. The infra repo (base-api.yaml.gotmpl) currently passes serviceMonitor.enabled at the top level — the corresponding infra PR must merge together with this one.

Changes

  • Move serviceMonitor and tracing under monitoring: section
  • Add monitoring.dashboard.enabled toggle for future Grafana sidecar provisioning
  • Add honorLabels, metricRelabeling, namespaceSelector to serviceMonitor
  • Default sampler to parentbased_always_on
  • Update values.schema.json to match new paths
  • Update docs (deployment.md, logging.md, config.md) and scripts/test-helm.sh

Test plan

  • make test-helm passes (21 tests)
  • Deploy with infra PR using OBSERVABILITY_ENABLED=true

@openshift-ci
openshift-ci Bot requested review from rh-amarin and tirthct August 5, 2026 11:04
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jsell-rh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/values.schema.json`:
- Around line 891-915: Extend the serviceMonitor schema definition with entries
for honorLabels, metricRelabeling, and namespaceSelector, using boolean, array,
and object types respectively to match the values consumed by
servicemonitor.yaml. Keep the existing serviceMonitor properties unchanged and
align each new definition with the corresponding values.yaml/template input.

In `@docs/deployment.md`:
- Around line 448-454: Update the Helm examples in the deployment documentation
so each monitoring variant is a complete, copy-pastable shell command: repeat
the full helm install command for the custom Prometheus selector and alternate
namespace examples, or connect all --set options with valid shell continuations.

In `@docs/logging.md`:
- Line 59: Update the logging documentation’s sampler configuration to use
parentbased_traceidratio instead of parentbased_always_on wherever the default
sampler is described, and keep OTEL_TRACES_SAMPLER_ARG=0.1 as the 10%
root-sampling value. Reconcile the fallback/default argument text in the logging
guide so the examples and explanatory sections consistently describe the same
sampler behavior, including the sections referenced by the existing sampler
settings and fallback descriptions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 17793209-8027-4e78-939f-01a497925735

📥 Commits

Reviewing files that changed from the base of the PR and between e8fb197 and 9116d53.

📒 Files selected for processing (9)
  • charts/README.md
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment thread charts/values.schema.json
Comment thread docs/deployment.md
Comment thread docs/logging.md Outdated
@hyperfleet-ci-bot

hyperfleet-ci-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

Risk Score: 1 — risk/low

Signal Detail Points
PR size 412 lines (>200) +1
Sensitive paths none +0

Computed by hyperfleet-risk-scorer

@Ruclo
Ruclo force-pushed the HYPERFLEET-1363 branch from 9116d53 to 57ada42 Compare August 5, 2026 11:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/templates/servicemonitor.yaml`:
- Line 1: Update the ServiceMonitor example in docs/metrics.md to use the
chart’s actual values path, monitoring.serviceMonitor.enabled, instead of the
obsolete root-level serviceMonitor.enabled. Keep the example aligned with the
ServiceMonitor template symbol .Values.monitoring.serviceMonitor.enabled so
copied configuration will render the resource correctly.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4e9a30f4-def7-4c2e-add1-2057c6d6e522

📥 Commits

Reviewing files that changed from the base of the PR and between e8fb197 and 57ada42.

📒 Files selected for processing (9)
  • charts/README.md
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (8)
  • docs/config.md
  • scripts/test-helm.sh
  • docs/deployment.md
  • charts/README.md
  • docs/logging.md
  • charts/templates/deployment.yaml
  • charts/values.yaml
  • charts/values.schema.json

Comment thread charts/templates/servicemonitor.yaml
@Ruclo
Ruclo force-pushed the HYPERFLEET-1363 branch from 57ada42 to 69d7acf Compare August 5, 2026 11:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/logging.md`:
- Around line 392-402: Update the default-sampling statement in the telemetry
documentation to match the runtime fallback in parseSamplingRate and
pkg/telemetry/otel.go: describe ParentBased(TraceIDRatioBased(...)) and clarify
that the configured rate applies to root spans while parent sampling decisions
are respected. Remove the claim that all traces are sampled by default, and
retain parentbased_always_on only as an explicitly configured sampler option.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f6b88f22-c5a7-4b92-863e-1d95fc23cc4b

📥 Commits

Reviewing files that changed from the base of the PR and between e8fb197 and 69d7acf.

📒 Files selected for processing (9)
  • charts/README.md
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (6)
  • scripts/test-helm.sh
  • charts/templates/deployment.yaml
  • charts/README.md
  • docs/config.md
  • docs/deployment.md
  • charts/values.schema.json

Comment thread docs/logging.md
@Ruclo

Ruclo commented Aug 5, 2026

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/templates/configmap-dashboard.yaml`:
- Around line 1-12: Increment the chart version in Chart.yaml from 1.1.0 to the
next version, keeping the existing parent revision unchanged, then run make
test-helm with Helm installed to verify the chart.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c336e75d-3489-482a-8e24-9ddf16af41c5

📥 Commits

Reviewing files that changed from the base of the PR and between e8fb197 and a8af034.

📒 Files selected for processing (10)
  • charts/README.md
  • charts/templates/configmap-dashboard.yaml
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (7)
  • docs/config.md
  • scripts/test-helm.sh
  • docs/logging.md
  • charts/values.schema.json
  • charts/values.yaml
  • docs/deployment.md
  • charts/templates/deployment.yaml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/Chart.yaml`:
- Line 5: Update the version advertised by the badge in charts/README.md from
1.1.0 to 1.2.0 so it matches the version declared in Chart.yaml.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 250b3fda-01c7-4b9d-8ec3-7a3f21c01090

📥 Commits

Reviewing files that changed from the base of the PR and between 822b124 and 1afdd5a.

📒 Files selected for processing (11)
  • charts/Chart.yaml
  • charts/README.md
  • charts/templates/configmap-dashboard.yaml
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (8)
  • docs/config.md
  • scripts/test-helm.sh
  • docs/deployment.md
  • docs/logging.md
  • charts/templates/deployment.yaml
  • charts/README.md
  • charts/values.schema.json
  • charts/values.yaml

Comment thread charts/Chart.yaml
description: HyperFleet API - Cluster Lifecycle Management Service
type: application
version: 1.1.0
version: 1.2.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the chart version in charts/README.md.

charts/Chart.yaml now declares version: 1.2.0, but charts/README.md:1 still advertises Version: 1.1.0. Update the README badge in this change so release documentation matches the chart metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@charts/Chart.yaml` at line 5, Update the version advertised by the badge in
charts/README.md from 1.1.0 to 1.2.0 so it matches the version declared in
Chart.yaml.

Source: Path instructions

@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
@openshift-hyperfleet openshift-hyperfleet deleted a comment from coderabbitai Bot Aug 6, 2026
…ng section

Consolidate all observability configuration under a single monitoring:
section for consistency across HyperFleet charts.

- Move serviceMonitor and tracing from top-level to monitoring section
- Add honorLabels, metricRelabeling, namespaceSelector to serviceMonitor
- Add dashboard toggle for future Grafana sidecar provisioning
- Default sampler to parentbased_always_on
@Ruclo
Ruclo force-pushed the HYPERFLEET-1363 branch from 1afdd5a to b8cb5f4 Compare August 6, 2026 09:41
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added optional Grafana dashboard provisioning through Helm.
    • Expanded monitoring configuration with ServiceMonitor customization, namespace selection, label handling, metric relabeling, and PodMonitoring support.
    • ServiceMonitor resources now default to the release namespace when unspecified.
  • Enhancements

    • Updated tracing defaults to enable sampling by default.
    • Updated Helm chart version to 1.2.0.
  • Documentation

    • Updated configuration, deployment, logging, and chart documentation for the new monitoring and tracing settings.

Walkthrough

The Helm chart version changes to 1.2.0. Monitoring values now nest ServiceMonitor and tracing settings under monitoring. ServiceMonitor supports namespace selection, label honoring, and metric relabelings. Optional Grafana dashboard ConfigMap provisioning and PodMonitoring schema are added. Tracing defaults change to parentbased_always_on. Documentation and Helm tests use the updated configuration paths.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: rh-amarin, tirthct, rafabene

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding Grafana dashboard provisioning to the Helm chart.
Description check ✅ Passed The description directly explains the Helm chart configuration, observability changes, documentation updates, and test plan.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sec-02: Secrets In Log Output ✅ Passed The PR diff contains no log statements. Non-test Go scans found no sensitive logging fields or fmt.Print* calls containing token, password, credential, or secret.
No Hardcoded Secrets ✅ Passed PASS: Added-line scans found no API keys, tokens, passwords, credential assignments, embedded URL credentials, or >32-character base64 strings; no CWE-798 finding.
No Weak Cryptography ✅ Passed PR changes Helm templates, values, and documentation only; no added banned primitives, custom crypto, or secret comparisons were found. Existing sha256sum use is unchanged.
No Injection Vectors ✅ Passed Changed files contain only Helm/docs/test updates; no SQL concatenation, exec.Command, template.HTML, or yaml.Unmarshal. The dashboard is static chart JSON embedded with .Files.Get.
No Privileged Containers ✅ Passed No privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation:true, or runAsUser:0 settings were added; Dockerfile USER root is documented for package installation and switches...
No Pii Or Sensitive Data In Logs ✅ Passed The PR changes only Helm, documentation, and test-script files; no logging statements or PII-bearing log arguments were added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/templates/configmap-dashboard.yaml`:
- Around line 1-12: Update the NOTES.txt template to document the
monitoring.dashboard.enabled value and explain that Grafana dashboard
provisioning requires the grafana_dashboard: "1" sidecar label used by the
hyperfleet-api dashboard ConfigMap.

In `@charts/templates/servicemonitor.yaml`:
- Around line 31-32: Validate monitoring.serviceMonitor.interval and
scrapeTimeout in charts/values.schema.json for supported Prometheus duration
syntax, and enforce that scrapeTimeout is not greater than interval while
allowing equal values. Update charts/templates/servicemonitor.yaml to fail
rendering when either duration is invalid or the timeout exceeds the interval,
rather than emitting values the Prometheus Operator will reject.

In `@charts/values.yaml`:
- Around line 435-453: Prevent the unused root-level serviceMonitor
configuration in values.yaml from silently passing validation: either wire
serviceMonitor.* to the monitoring.serviceMonitor implementation as an explicit
compatibility alias, or reject it with a clear migration error directing users
to monitoring.serviceMonitor.*. Update docs/metrics.md and chart API consumers
to use the supported path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 3df4aea8-c083-46ab-866c-39740442b53e

📥 Commits

Reviewing files that changed from the base of the PR and between cf39733 and b8cb5f4.

📒 Files selected for processing (11)
  • charts/Chart.yaml
  • charts/README.md
  • charts/templates/configmap-dashboard.yaml
  • charts/templates/deployment.yaml
  • charts/templates/servicemonitor.yaml
  • charts/values.schema.json
  • charts/values.yaml
  • docs/config.md
  • docs/deployment.md
  • docs/logging.md
  • scripts/test-helm.sh
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment on lines +1 to +12
{{- if .Values.monitoring.dashboard.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hyperfleet-api.fullname" . }}-grafana-dashboard
labels:
{{- include "hyperfleet-api.labels" . | nindent 4 }}
grafana_dashboard: "1"
data:
hyperfleet-api.json: |-
{{- .Files.Get "dashboards/hyperfleet-api.json" | nindent 4 }}
{{- end }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update charts/templates/NOTES.txt for dashboard provisioning.

This template adds the user-facing monitoring.dashboard.enabled feature. Document the enablement value and the Grafana sidecar label requirement in charts/templates/NOTES.txt.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@charts/templates/configmap-dashboard.yaml` around lines 1 - 12, Update the
NOTES.txt template to document the monitoring.dashboard.enabled value and
explain that Grafana dashboard provisioning requires the grafana_dashboard: "1"
sidecar label used by the hyperfleet-api dashboard ConfigMap.

Source: Path instructions

Comment on lines +31 to +32
interval: {{ .Values.monitoring.serviceMonitor.interval }}
scrapeTimeout: {{ .Values.monitoring.serviceMonitor.scrapeTimeout }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- target template ---'
cat -n charts/templates/servicemonitor.yaml | sed -n '1,90p'

printf '%s\n' '--- values and schema sections ---'
rg -n -C 12 '"serviceMonitor"|"interval"|"scrapeTimeout"|serviceMonitor:' charts/values.yaml charts/values.schema.json

printf '%s\n' '--- chart documentation and version ---'
rg -n -C 8 'scrapeTimeout|serviceMonitor|monitoring' charts README.md docs 2>/dev/null || true
cat -n charts/Chart.yaml | sed -n '1,80p'

printf '%s\n' '--- chart tests or validation helpers ---'
rg -n 'fail |required |regex|scrapeTimeout|helm template|ServiceMonitor' charts .github 2>/dev/null || true

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 50393


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relevant chart diff ---'
git diff -- charts/templates/servicemonitor.yaml charts/values.yaml charts/values.schema.json charts/Chart.yaml docs/metrics.md docs/deployment.md | sed -n '1,260p'

printf '%s\n' '--- validation patterns ---'
rg -n -C 4 'pattern|minimum|maximum|fail |required |regexMatch|duration' charts/values.schema.json charts/templates charts/tests 2>/dev/null | sed -n '1,260p'

printf '%s\n' '--- ServiceMonitor duration references in related charts ---'
rg -n -C 5 'scrapeTimeout|interval' charts 2>/dev/null | sed -n '1,220p'

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 17014


🌐 Web query:

Prometheus Operator ServiceMonitor endpoint scrapeTimeout must be less than interval validation

💡 Result:

Yes, the Prometheus Operator enforces that the scrapeTimeout value defined in a ServiceMonitor must be less than or equal to the defined scrape interval [1][2]. If the scrapeTimeout is configured to be greater than the scrape interval, the Prometheus Operator will reject the ServiceMonitor resource [1][3]. This validation is implemented to ensure efficient and logical scraping behavior, as a scrape cannot logically time out after a duration longer than the interval at which it is triggered [4]. In the Prometheus Operator API, the scrapeTimeout field is optional; if it is not explicitly defined, Prometheus uses the global scrape timeout, provided that the global value is not itself greater than the target's scrape interval (in which case the interval is used as the timeout) [2][3]. The validation logic is handled within the Prometheus Operator's reconciliation and selection processes [5]. While earlier versions relied solely on internal Go-based validation [4][5], the operator ensures consistency across resource types—including ServiceMonitors, PodMonitors, and Probes—to prevent invalid scrape configurations [4][6].

Citations:


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

curl -fsSL \
  https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/Documentation/api.md \
  -o "$tmpdir/api.md"

curl -fsSL \
  https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/pkg/apis/monitoring/v1/servicemonitor_types.go \
  -o "$tmpdir/servicemonitor_types.go"

printf '%s\n' '--- scrapeTimeout documentation ---'
rg -n -C 8 'scrapeTimeout|ScrapeTimeout|interval' "$tmpdir/api.md" "$tmpdir/servicemonitor_types.go"

printf '%s\n' '--- validation implementation references ---'
curl -fsSL \
  https://api.github.com/search/code?q=repo%3Aprometheus-operator%2Fprometheus-operator+scrapeTimeout+interval+language%3AGo \
  | jq -r '.message // empty, (.items[]?.html_url // empty)' || true

Length of output: 176


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import json
from pathlib import Path

schema = json.loads(Path("charts/values.schema.json").read_text())
sm = schema["properties"]["monitoring"]["properties"]["serviceMonitor"]["properties"]

for name in ("interval", "scrapeTimeout"):
    print(name, json.dumps(sm[name], indent=2))

for value in ("30s", "10s", "0s", "-1s", "not-a-duration", "1h30m"):
    print("schema-shape", value, isinstance(value, str))
PY

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 501


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re

# Prometheus model durations use the sequence of number+unit terms:
# ms, s, m, h, d, w, y.
pattern = re.compile(r"^(?:0|[1-9][0-9]*(?:ms|s|m|h|d|w|y))+$")

cases = {
    "30s": True,
    "10s": True,
    "1h30m": True,
    "0s": True,
    "-1s": False,
    "not-a-duration": False,
    "10 seconds": False,
}
for value, expected_syntax in cases.items():
    actual = bool(pattern.fullmatch(value))
    print(f"{value!r}: syntax={actual}, expected={expected_syntax}")
PY

Length of output: 389


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

for url in \
  "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/pkg/apis/monitoring/v1/types.go" \
  "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml" \
  "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/pkg/prometheus/promcfg.go"
do
  file="$tmpdir/$(basename "$url")"
  curl -fsSL "$url" -o "$file"
done

rg -n -C 10 'scrapeTimeout|ScrapeTimeout|interval|Interval|must be less|greater than' "$tmpdir"

Length of output: 50343


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re

# Prometheus Operator's ServiceMonitor CRD accepts this duration grammar.
duration = re.compile(
    r"^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?"
    r"(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$"
)
units = {"ms": 1, "s": 1000, "m": 60_000, "h": 3_600_000,
         "d": 86_400_000, "w": 604_800_000, "y": 31_536_000_000}

def milliseconds(value):
    if not duration.fullmatch(value):
        return None
    total = 0
    for number, unit in re.findall(r"([0-9]+)(y|w|d|h|m|s|ms)", value):
        total += int(number) * units[unit]
    return total

def operator_result(interval, timeout):
    i, t = milliseconds(interval), milliseconds(timeout)
    if i is None or t is None:
        return "reject: invalid duration"
    return "reject: timeout greater than interval" if t > i else "accept"

for interval, timeout in [
    ("30s", "10s"),
    ("10s", "10s"),
    ("30s", "40s"),
    ("30s", "not-a-duration"),
    ("not-a-duration", "10s"),
]:
    print(f"interval={interval}, scrapeTimeout={timeout}: {operator_result(interval, timeout)}")
PY

Length of output: 414


Reject invalid ServiceMonitor scrape durations before rendering.

The schema accepts arbitrary strings, and the template renders them directly. Values such as not-a-duration or scrapeTimeout: 40s with interval: 30s cause the Prometheus Operator to reject the ServiceMonitor. Add duration syntax validation and fail when scrapeTimeout is greater than interval; equal durations are valid.

📍 Affects 2 files
  • charts/templates/servicemonitor.yaml#L31-L32 (this comment)
  • charts/values.schema.json#L899-L905
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@charts/templates/servicemonitor.yaml` around lines 31 - 32, Validate
monitoring.serviceMonitor.interval and scrapeTimeout in
charts/values.schema.json for supported Prometheus duration syntax, and enforce
that scrapeTimeout is not greater than interval while allowing equal values.
Update charts/templates/servicemonitor.yaml to fail rendering when either
duration is invalid or the timeout exceeds the interval, rather than emitting
values the Prometheus Operator will reject.

Source: Path instructions

Comment thread charts/values.yaml
Comment on lines +435 to +453
# -- ServiceMonitor for Prometheus Operator scrape configuration
serviceMonitor:
# -- Create a ServiceMonitor resource
enabled: false
# -- Scrape interval
interval: 30s
# -- Scrape timeout (must be less than interval)
scrapeTimeout: 10s
# -- Additional labels for ServiceMonitor discovery
labels: {}
# -- Honor labels from the target to avoid overwriting
honorLabels: true
# -- Metric relabel configs applied before ingestion
metricRelabeling: []
# -- Namespace selector for cross-namespace monitoring
namespaceSelector: {}
# -- Namespace to create the ServiceMonitor in (defaults to release namespace)
namespace: ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- local legacy value references ---'
rg -n -C 2 '(^|[^[:alnum:]_])serviceMonitor\.(enabled|interval|scrapeTimeout|labels|namespace)|^[[:space:]]*serviceMonitor:[[:space:]]*$' .

printf '%s\n' '--- organization-wide legacy value references ---'
gh search code 'serviceMonitor.enabled org:openshift-hyperfleet' --limit 100

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 10448


🏁 Script executed:

set -euo pipefail

printf '%s\n' '--- chart files and current references ---'
git ls-files charts docs scripts | sed -n '1,160p'
rg -n -C 3 'serviceMonitor|monitoring:' charts/values.yaml charts/templates/servicemonitor.yaml charts/README.md docs/deployment.md docs/metrics.md scripts/test-helm.sh || true

printf '%s\n' '--- chart schema and version ---'
fd -i 'values.schema.json|Chart.yaml|NOTES.txt' charts -x sh -c 'echo --- "$1"; cat -n "$1"' sh {} \;

printf '%s\n' '--- branch change summary ---'
git diff --stat
git diff -- charts/values.yaml charts/templates/servicemonitor.yaml charts/README.md docs/deployment.md docs/metrics.md scripts/test-helm.sh | sed -n '1,260p'

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 50393


🏁 Script executed:

set -euo pipefail

printf '%s\n' '--- adapter documentation references ---'
rg -n -C 3 'serviceMonitor|monitoring\.serviceMonitor' hyperfleet/components/adapter/framework/adapter-deployment.md || true

Repository: openshift-hyperfleet/architecture

Length of output: 316


🏁 Script executed:

set -euo pipefail

python3 - <<'PY'
import json
from pathlib import Path

schema = json.loads(Path("charts/values.schema.json").read_text())
print("root additionalProperties:", schema.get("additionalProperties", "<omitted: JSON Schema default is true>"))
print("root serviceMonitor property:", "serviceMonitor" in schema.get("properties", {}))
monitoring = schema.get("properties", {}).get("monitoring", {})
print("monitoring additionalProperties:", monitoring.get("additionalProperties", "<omitted: JSON Schema default is true>"))
print("monitoring properties:", sorted(monitoring.get("properties", {})))
sm = monitoring.get("properties", {}).get("serviceMonitor", {})
print("monitoring.serviceMonitor additionalProperties:", sm.get("additionalProperties", "<omitted: JSON Schema default is true>"))
print("monitoring.serviceMonitor properties:", sorted(sm.get("properties", {})))
PY

printf '%s\n' '--- legacy-path handling ---'
rg -n -C 3 '(^|[^[:alnum:]_])serviceMonitor(\.enabled|:)|legacy|deprecated|migration' charts/templates charts/values.schema.json charts/values.yaml scripts docs/metrics.md || true

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 2046


🏁 Script executed:

set -euo pipefail

python3 - <<'PY'
from copy import deepcopy

defaults = {
    "monitoring": {
        "serviceMonitor": {
            "enabled": False,
            "interval": "30s",
            "scrapeTimeout": "10s",
            "labels": {},
            "honorLabels": True,
            "metricRelabeling": [],
            "namespaceSelector": {},
            "namespace": "",
        }
    }
}

def helm_set(defaults, path, value):
    merged = deepcopy(defaults)
    node = merged
    parts = path.split(".")
    for part in parts[:-1]:
        node = node.setdefault(part, {})
    node[parts[-1]] = value
    return merged

for label, values in [
    ("root-only", helm_set(defaults, "serviceMonitor.enabled", True)),
    ("nested-only", helm_set(defaults, "monitoring.serviceMonitor.enabled", True)),
    ("both", helm_set(helm_set(defaults, "serviceMonitor.enabled", True),
                      "monitoring.serviceMonitor.enabled", False)),
]:
    nested_enabled = values["monitoring"]["serviceMonitor"]["enabled"]
    print(f"{label}: root={values.get('serviceMonitor', {}).get('enabled')!r}, "
          f"monitoring.serviceMonitor.enabled={nested_enabled!r}, "
          f"ServiceMonitor rendered={nested_enabled}")
PY

Repository: openshift-hyperfleet/hyperfleet-api

Length of output: 447


Reject legacy serviceMonitor.* values (CWE-16).

The chart renders ServiceMonitor only when monitoring.serviceMonitor.enabled is true. Root-level serviceMonitor.enabled=true passes schema validation but is ignored. Keep a compatibility alias or reject the legacy path with a migration error. Update docs/metrics.md and API chart consumers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@charts/values.yaml` around lines 435 - 453, Prevent the unused root-level
serviceMonitor configuration in values.yaml from silently passing validation:
either wire serviceMonitor.* to the monitoring.serviceMonitor implementation as
an explicit compatibility alias, or reject it with a clear migration error
directing users to monitoring.serviceMonitor.*. Update docs/metrics.md and chart
API consumers to use the supported path.

Sources: Path instructions, Linked repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant