VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
406 stars 142 forks source link

conversion of scrapeconfig fails #942

Closed fenio closed 2 months ago

fenio commented 2 months ago

Hey,

I've created the following Prometheus scrape config:

apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  name: &name smartctl-exporter-nas
spec:
  staticConfigs: [targets: ["10.10.20.100:30000"]]
  metricsPath: /metrics
  honorTimestamps: true
  relabelings:
    - action: replace
      targetLabel: job
      replacement: *name

Which after all flux and k8s magic ended up to be:

  apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  creationTimestamp: "2024-04-27T08:59:40Z"
  generation: 1
  labels:
    app.kubernetes.io/name: smartctl-exporter
    kustomize.toolkit.fluxcd.io/name: smartctl-exporter
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: smartctl-exporter-nas
  namespace: o11y
  resourceVersion: "1560700"
  uid: 3905aaca-b467-4cde-bae4-82acaea71551
spec:
  honorTimestamps: true
  metricsPath: /metrics
  relabelings:
  - action: replace
    replacement: smartctl-exporter-nas
    targetLabel: job
  staticConfigs:
  - targets:
    - 10.10.20.100:30000

Seems that vm-operator while trying to convert it to VMScrapeConfig it tries to do some weird stuff with "resourceVersion" entity... I guess it shouldn't try to convert it. Not sure if it tries same stuff with uuid. Anyway it fails:

{"level":"error","ts":"2024-04-27T09:02:06Z","logger":"controller","msg":"cannot get existing vmScrapeConfig","kind":"vmScrapeConfig","name":"smartctl-exporter-nas","ns":"o11y","error":"resourceVersion should not be set on objects to be created","stacktrace":"github.com/VictoriaMetrics/operator/controllers.(*ConverterController).UpdateScrapeConfig\n\tgithub.com/VictoriaMetrics/operator/controllers/vmprometheusconverter_controller.go:651\nk8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnUpdate\n\tk8s.io/client-go@v12.0.0+incompatible/tools/cache/controller.go:250\nk8s.io/client-go/tools/cache.(*processorListener).run.func1\n\tk8s.io/client-go@v12.0.0+incompatible/tools/cache/shared_informer.go:971\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\tk8s.io/apimachinery@v0.29.2/pkg/util/wait/backoff.go:226\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\tk8s.io/apimachinery@v0.29.2/pkg/util/wait/backoff.go:227\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\tk8s.io/apimachinery@v0.29.2/pkg/util/wait/backoff.go:204\nk8s.io/apimachinery/pkg/util/wait.Until\n\tk8s.io/apimachinery@v0.29.2/pkg/util/wait/backoff.go:161\nk8s.io/client-go/tools/cache.(*processorListener).run\n\tk8s.io/client-go@v12.0.0+incompatible/tools/cache/shared_informer.go:967\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tk8s.io/apimachinery@v0.29.2/pkg/util/wait/wait.go:72"}
f41gh7 commented 2 months ago

Changes included to the v0.44.0 release