Skip to content

feat: attachMetadata.resources instead of a namespace bool - #2

Merged
dongjiang1989 merged 1 commit into
kubeservice-stack:add-namespace-metadatafrom
2youio:attach-metadata-resources
Nov 17, 2026
Merged

dongjiang1989 merged 1 commit into
kubeservice-stack:add-namespace-metadatafrom
2youio:attach-metadata-resources

Conversation

@mkhon

@mkhon mkhon commented Nov 17, 2026

Copy link
Copy Markdown

Stacked on prometheus-operator#7811: implements the API asked for in its latest review, a set of resources instead of one boolean per kind.

attachMetadata:
  resources: [Node, Namespace]   # +listType=set, enum Node;Namespace
  node: true                     # still accepted, deprecated
  • resources in v1 and v1alpha1 AttachMetadata; the namespace field of feat: Add support for attaching namespace metadata to Kubernetes SD prometheus-operator/prometheus-operator#7811 goes. node stays, deprecated.
  • HasResource/WithResource on AttachMetadata, so the config generator reads both fields in one place.
  • ScrapeConfig CEL rules check node metadata from either field and namespace metadata from resources.
  • Topology sharding adds Node to what was requested and keeps the rest (the review's "what if namespace == true?").
  • Clients, deepcopy, CRDs, jsonnet, bundle and API docs regenerated.

Tests: unit tests for both helpers; goldens for a namespace-only ScrapeConfig and for a topology-sharded PodMonitor with namespace only; the existing cases of prometheus-operator#7811 use resources, two keep the deprecated node (goldens unchanged); e2e CRD validation cases for disallowed roles, an unknown resource and a duplicate. go test ./pkg/prometheus/... ./pkg/apis/monitoring/v1 passes; the e2e cases are compiled, not run.

🤖 Generated with Claude Code

As requested in review: attachMetadata lists the objects whose metadata
is attached, as a set, instead of one boolean per kind.

- add `resources` (`Node`, `Namespace`) to v1 and v1alpha1 AttachMetadata;
  `node` stays and is deprecated
- drop the `namespace` field added earlier in this PR
- ScrapeConfig CEL rules check node metadata from either field, and
  namespace metadata from `resources`
- topology sharding adds `Node` to the requested resources and keeps
  the others

Assisted-by: Claude Opus 5.5
Signed-off-by: Maxim Khon <max@2you.io>
@CLAassistant

CLAassistant commented Nov 17, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 512aee8e-7345-4e68-986b-9ced28256ff2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dongjiang1989
dongjiang1989 merged commit 45f049e into kubeservice-stack:add-namespace-metadata Nov 17, 2026
2 of 3 checks passed
@mkhon
mkhon deleted the attach-metadata-resources branch November 17, 2026 12:07
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.

3 participants