Skip to content

fix: preserve single regex values in converted ServiceMonitors#2373

Open
immanuwell wants to merge 1 commit into
VictoriaMetrics:masterfrom
immanuwell:fix/servicemonitor-regex-json
Open

fix: preserve single regex values in converted ServiceMonitors#2373
immanuwell wants to merge 1 commit into
VictoriaMetrics:masterfrom
immanuwell:fix/servicemonitor-regex-json

Conversation

@immanuwell

Copy link
Copy Markdown
Contributor

Related to #1219

StringOrArray was marshaling nested single values as JSON arrays, so converted ServiceMonitor objects could send regex: ["..."] instead of regex: "...". That makes VMServiceScrape validation blow up.

This switches MarshalJSON to a value receiver, so converted relabel regex fields stay strings. Tiny fix, low risk.

Repro:

  1. Install Prometheus Operator and VictoriaMetrics Operator.
  2. Create a ServiceMonitor with single-string regex in metricRelabelings or relabelings.
  3. Current master can reject the generated VMServiceScrape with regex ... must be of type string: "array".
  4. This branch keeps regex as a JSON string, so the converted object goes through.

Tests:
go test ./internal/controller/operator/factory/converter
cd api && go test ./operator/v1beta1

Signed-off-by: immanuwell <pchpr.00@list.ru>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant