Skip to content

Fix metric names linter to handle recording rules separately#3980

Merged
kubevirt-bot merged 1 commit into
kubevirt:mainfrom
avlitman:fix-metric-linter
Dec 17, 2025
Merged

Fix metric names linter to handle recording rules separately#3980
kubevirt-bot merged 1 commit into
kubevirt:mainfrom
avlitman:fix-metric-linter

Conversation

@avlitman
Copy link
Copy Markdown
Contributor

@avlitman avlitman commented Dec 11, 2025

What this PR does

Before this PR:

recording rules and metrics sent as metrics to metrics name linter which handled them same

After this PR:

recording rules and metrics sent as 2 list (in the same file as before) to metrics name linter which handle them separately

Fixes #
jira-ticket: https://issues.redhat.com/browse/CNV-73602

Why we need it and why it was done in this way

The plan is to add duplicate recording rules with correct name and deprecate the old recording rules after a few versions.
This is what we were asked to do by the openshift observability team that need to be able to distinguish recording rules from metrics.
This linter updat will make sure no new wrong naming recording rules will be added.

The following tradeoffs were made:

To avoid breaking existing rules, the linter (in the monitoring repo) will include an operator-scoped allowlist for current names, any new rule that isn’t on that list will fail CI. this keeps all policy and exceptions in the monitoring repo (no future kubevirt changes), and in a couple of versions, once old names are gone, we just remove the allowlist from monitoring and bump the linter version in kubevirt.

The following alternatives were considered:

keep testing the rules as metrics like we do now, and fix the linter only when wrong names is deprecated.
since the linter fails also with this solution and to enforces correct naming for all new rules immediately we decided to implement the new linter now and allowlist the existing wrong rules name that will fail the new linter.

Release note

none

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Dec 11, 2025
This pr lint-metrics to send recording rules and metrics as 2 list (in
the same file as before) to metrics name linter which handle them
separately.

Signed-off-by: alitman <alitman@alitman-thinkpadp1gen7.raanaii.csb>
Signed-off-by: Aviv Litman <alitman@alitman-thinkpadp1gen7.raanaii.csb>
@coveralls
Copy link
Copy Markdown

coveralls commented Dec 11, 2025

Coverage Status

coverage: 58.705% (+0.006%) from 58.699%
when pulling f85bf5c on avlitman:fix-metric-linter
into e147bbd on kubevirt:main.

@avlitman
Copy link
Copy Markdown
Contributor Author

cc @akalenyu @aglitke

Type: strings.ToUpper(string(r.GetType())),
})
name := r.GetOpts().Name
if _, isExcludedMetric := excludedMetrics[name]; isExcludedMetric {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe i'm missing something, but does this map ever get populated?

Copy link
Copy Markdown
Contributor Author

@avlitman avlitman Dec 16, 2025

Choose a reason for hiding this comment

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

it can be, we decided to leave it for all operators in case you must ignore some metric for good reason and to have this logic enabled in case it's needed.

@dsanatar
Copy link
Copy Markdown
Collaborator

Looks pretty good! just had a quick question

@dsanatar
Copy link
Copy Markdown
Collaborator

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 16, 2025
Copy link
Copy Markdown
Collaborator

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

/approve
🙏

@kubevirt-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akalenyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2025
@kubevirt-bot kubevirt-bot merged commit e1bfde0 into kubevirt:main Dec 17, 2025
21 checks passed
Acedus pushed a commit to Acedus/containerized-data-importer that referenced this pull request Dec 17, 2025
…t#3980)

This pr lint-metrics to send recording rules and metrics as 2 list (in
the same file as before) to metrics name linter which handle them
separately.

Signed-off-by: alitman <alitman@alitman-thinkpadp1gen7.raanaii.csb>
Signed-off-by: Aviv Litman <alitman@alitman-thinkpadp1gen7.raanaii.csb>
Co-authored-by: Aviv Litman <alitman@alitman-thinkpadp1gen7.raanaii.csb>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants