Skip to content

feat: support group-level labels for rule-group resources - #75

Merged
fgouteroux merged 1 commit into
fgouteroux:mainfrom
sandrom:feat/group-level-labels
Jun 30, 2026
Merged

feat: support group-level labels for rule-group resources#75
fgouteroux merged 1 commit into
fgouteroux:mainfrom
sandrom:feat/group-level-labels

Conversation

@sandrom

@sandrom sandrom commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for group-level labels on rule-group resources. A rule group can carry labels applied to all of its rules (commonly used for notification routing, e.g. target_channel). Previously the provider dropped group-level labels entirely.

This covers all three rule-group resources:

  • mimir_rule_group_alerting / mimir_rule_group_recording (typed): new optional top-level labels map (TypeMap), expanded into the group on Create/Update, included in the HasChanges gate so a label-only edit triggers an update, and set back from the API on Read for a drift-free round-trip.
  • mimir_rules (combined YAML): adds the Labels field to the RuleGroup struct so a group-level labels: key in the YAML content/content_file reaches the backend (POST body) and the content hash, instead of being silently dropped on unmarshal.

Version requirement

Group-level rule-group labels are only persisted by Mimir >= 3.0.0 (Prometheus added the rulefmt group Labels field in 3.0.0; Mimir's ruler honours it from 3.0.0). On older Mimir the config API accepts the labels but drops them. This is documented on each schema attribute's description. On a typed resource against Mimir < 3.0.0 this means a non-converging plan (the server returns no labels); the requirement is documented rather than enforced at runtime.

Tests

  • Unit: TestRuleGroupContentPreservesGroupLabels — group labels survive the parse → marshal round-trip used by Create and the content hash.
  • Acceptance (version-gated, skipped < 3.0.0): TestAccResourceRuleGroupAlerting_GroupLabels, TestAccResourceRuleGroupRecording_GroupLabels, TestAccResourceMimirRules_GroupLabels — create without labels, add labels (exercises the HasChanges gate), change the value, and (for mimir_rules) assert via the ruler API + a no-drift re-apply.
  • make testacc passes on Mimir 3.0.6 and 2.17.10 (the group-label tests --- SKIP on 2.17.10); golangci-lint clean; docs regenerated via tfplugindocs.

@sandrom
sandrom force-pushed the feat/group-level-labels branch 2 times, most recently from c92b1ea to d2ec0c2 Compare June 29, 2026 14:18
Add a group-level `labels` map to mimir_rule_group_alerting,
mimir_rule_group_recording, and the combined mimir_rules resource. Group
labels are applied to all rules in a group (e.g. for notification
routing) and were previously dropped by the provider.

- typed resources: new optional `labels` TypeMap, expanded in
  Create/Update, included in the HasChanges gate, and read back in Read
  for a drift-free round-trip.
- mimir_rules: add the `Labels` field to the RuleGroup struct so
  group-level labels in the YAML content reach the backend (POST body)
  and the content hash.

Group-level labels require Mimir >= 3.0.0 to be persisted; older Mimir
accepts but silently drops them. This is documented on the schema
attribute descriptions. Adds version-gated acceptance tests (skipped
below 3.0.0) for all three resources plus a unit round-trip test; passes
make testacc on Mimir 3.0.6 and 2.17.10.

Refs: EDPIPIF-1516
Signed-off-by: Sandro Manke <hello@sandrom.de>
@sandrom
sandrom force-pushed the feat/group-level-labels branch from d2ec0c2 to 36da7ef Compare June 29, 2026 14:21
@sandrom
sandrom marked this pull request as ready for review June 29, 2026 14:23
@fgouteroux

Copy link
Copy Markdown
Owner

Oh nice thanks @sandrom

@fgouteroux
fgouteroux self-requested a review June 30, 2026 17:58
@fgouteroux
fgouteroux merged commit 0960b0e into fgouteroux:main Jun 30, 2026
4 checks passed
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.

2 participants