Fix metrics generator panic when write_relabel_configs is set - #6399
Conversation
3610c5d to
82e7dcc
Compare
82e7dcc to
3ad14a2
Compare
| // mutate the shared input configs. Without this, concurrent | ||
| // watchOverrides goroutines from different tenants would race on | ||
| // the shared *relabel.Config objects. | ||
| output.WriteRelabelConfigs = copyRelabelConfigs(input.WriteRelabelConfigs) |
There was a problem hiding this comment.
I don’t think the deep copy is needed here if we validate the base config once at startup. cfg.RemoteWrite is global (not tenant-specific), so we can initialize/validate its relabel configs when the metrics generator starts.
In generateTenantRemoteWriteConfigs, we only inject per-tenant headers. Doing validation once would simplify this path and avoid per-tenant allocations. Per-tenant path should just clone config as it is right now and inject headers.
There was a problem hiding this comment.
good point. The whole issue was that the Validate from Prometheus sets one field: https://github.com/carles-grafana/tempo/blob/fix_config_panic/vendor/github.com/prometheus/prometheus/model/relabel/relabel.go#L135
by moving it to startup it's much simpler. fixed
…a#6396) The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR prometheus/prometheus#16928) moved label name validation from a global to a per-config NameValidationScheme field on relabel.Config. This field must be initialized by calling Validate() before use, otherwise relabeling panics with "Invalid name validation scheme requested: unset". Tempo constructs RemoteWriteConfig programmatically rather than going through Prometheus's config.Load() path, so Validate() was never called. Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup in storage.Config.Validate(), which initializes NameValidationScheme on all write relabel configs before any tenant storage instances are created. Also fix a pre-existing bug in watchOverrides where cached state was updated before ApplyConfig succeeded, preventing retries on failure.
b55b38d to
85e52e2
Compare
javiermolinar
left a comment
There was a problem hiding this comment.
LGTM
Have you tested it with our docker example?
|
yes, tested with docker successfully |
…#6399) The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR prometheus/prometheus#16928) moved label name validation from a global to a per-config NameValidationScheme field on relabel.Config. This field must be initialized by calling Validate() before use, otherwise relabeling panics with "Invalid name validation scheme requested: unset". Tempo constructs RemoteWriteConfig programmatically rather than going through Prometheus's config.Load() path, so Validate() was never called. Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup in storage.Config.Validate(), which initializes NameValidationScheme on all write relabel configs before any tenant storage instances are created. Also fix a pre-existing bug in watchOverrides where cached state was updated before ApplyConfig succeeded, preventing retries on failure.
…#6399) (#6455) The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR prometheus/prometheus#16928) moved label name validation from a global to a per-config NameValidationScheme field on relabel.Config. This field must be initialized by calling Validate() before use, otherwise relabeling panics with "Invalid name validation scheme requested: unset". Tempo constructs RemoteWriteConfig programmatically rather than going through Prometheus's config.Load() path, so Validate() was never called. Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup in storage.Config.Validate(), which initializes NameValidationScheme on all write relabel configs before any tenant storage instances are created. Also fix a pre-existing bug in watchOverrides where cached state was updated before ApplyConfig succeeded, preventing retries on failure.
…a#6396) (grafana#6399) The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR prometheus/prometheus#16928) moved label name validation from a global to a per-config NameValidationScheme field on relabel.Config. This field must be initialized by calling Validate() before use, otherwise relabeling panics with "Invalid name validation scheme requested: unset". Tempo constructs RemoteWriteConfig programmatically rather than going through Prometheus's config.Load() path, so Validate() was never called. Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup in storage.Config.Validate(), which initializes NameValidationScheme on all write relabel configs before any tenant storage instances are created. Also fix a pre-existing bug in watchOverrides where cached state was updated before ApplyConfig succeeded, preventing retries on failure.
What this PR does:
Fix metrics generator panic when write_relabel_configs is set (#6396)
The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
prometheus/prometheus#16928) moved label name validation from a global
to a per-config NameValidationScheme field on relabel.Config. This field
must be initialized by calling Validate() before use, otherwise
relabeling panics with "Invalid name validation scheme requested: unset".
Tempo constructs RemoteWriteConfig programmatically rather than going
through Prometheus's config.Load() path, so Validate() was never called.
Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
in storage.Config.Validate(), which initializes NameValidationScheme on
all write relabel configs before any tenant storage instances are created.
Also fix a pre-existing bug in watchOverrides where cached state was
updated before ApplyConfig succeeded, preventing retries on failure.
Which issue(s) this PR fixes:
Fixes #6396
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]