Fix metric names linter to handle recording rules separately#3980
Merged
Conversation
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>
8ff93cb to
f85bf5c
Compare
Contributor
Author
dsanatar
reviewed
Dec 16, 2025
| Type: strings.ToUpper(string(r.GetType())), | ||
| }) | ||
| name := r.GetOpts().Name | ||
| if _, isExcludedMetric := excludedMetrics[name]; isExcludedMetric { |
Collaborator
There was a problem hiding this comment.
maybe i'm missing something, but does this map ever get populated?
Contributor
Author
There was a problem hiding this comment.
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.
Collaborator
|
Looks pretty good! just had a quick question |
Collaborator
|
/lgtm |
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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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