Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply monitoring linters #11454

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

assafad
Copy link
Contributor

@assafad assafad commented Mar 6, 2024

What this PR does

Apply the following linters:

  • monitoringlinter that was implemented in Add monitoring linter monitoring#221, and was designed to enforce proposal: Monitoring code refactor community#219.
    This linter ensures that all monitoring-related practices are implemented within the pkg/monitoring directory using operator-observability methods. It verifies that all metrics, alerts and recording rules registrations are centralized in this directory, and restricts the direct use of Prometheus registration methods.
    Example for a message reported by the linter:

    kubevirt/pkg/virt-controller/watch/workload-updater/workload-updater.go:67:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
    
  • operator-observability rules linter - ensures that alerts and recording rules definitions are following the monitoring best practices, e.g. alerts have all the required annotations and labels with expected values, recording rules have expressions, etc. In addition, bump operator-observability for it.

Fixes https://issues.redhat.com/browse/CNV-36761

Special notes for your reviewer:

Depending on #11184 and https://issues.redhat.com/browse/CNV-39013.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

None

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 Mar 6, 2024
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
@assafad assafad force-pushed the monitoring-linters branch 3 times, most recently from dc1cacf to 0a1aaa7 Compare March 6, 2024 16:05
@assafad assafad marked this pull request as ready for review March 6, 2024 16:07
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 6, 2024
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_suite_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_suite_test.go Outdated Show resolved Hide resolved
pkg/monitoring/rules/rules_test.go Outdated Show resolved Hide resolved
@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2024
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2024
@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2024
Makefile Outdated Show resolved Hide resolved
@assafad
Copy link
Contributor Author

assafad commented Mar 7, 2024

Since the monitoring refactoring is still WIP (should be completed by #11184 and https://issues.redhat.com/browse/CNV-39013), currently the monitoring linter gives:

monitoringlinter ./pkg/...
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/client/prometheus/prometheus.go:95:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/client/prometheus/prometheus.go:96:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/client/prometheus/prometheus.go:97:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/domainstats/prometheus/prometheus.go:584:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:79:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:80:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:81:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:82:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:83:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:84:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:85:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus/prometheus.go:86:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:54:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:66:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:79:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:92:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:104:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:117:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus/prometheus.go:132:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
/root/go/src/kubevirt.io/kubevirt/pkg/virt-controller/watch/workload-updater/workload-updater.go:67:2: monitoring-linter: metrics should be registered only within pkg/monitoring directory, using operator-observability packages.
make: *** [Makefile:225: lint] Error 1

@iholder101
Copy link
Contributor

General direction seems great to me.
Thanks for your efforts @assafad! Great work!

/approve

However, since I'm not familiar with all of the details, I'd like others that were involved to have a look and have time to give feedback. Let's hold the PR until the involved people review.

/hold

@sradco @machadovilaca @nunnatsa @RamLavi - would you be able to review?
FYI @enp0s3 @vladikr

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iholder101

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

The pull request process is described here

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 Mar 14, 2024
@victortoso
Copy link
Member

victortoso commented Mar 15, 2024

I'd suggest adding in the Special notes for your reviewer: of the first comment this PR depends on kubevirt/community#219 #11184 (and others?) and moving it to Draft while those dependencies don't get merged.

Apply monitoringlinter that enforces the monitoring refactoring.

Signed-off-by: assafad <aadmi@redhat.com>
@assafad assafad marked this pull request as ready for review April 10, 2024 09:54
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 10, 2024
@assafad assafad force-pushed the monitoring-linters branch 2 times, most recently from 05bdbc2 to e9ec5a2 Compare April 10, 2024 11:17
Apply operator-observability rules linter to ensure kubevirt
alerts and recording rules definitions are following monitoring best
practices.

Signed-off-by: aadmi <aadmi@redhat.com>
@kubevirt-bot
Copy link
Contributor

@assafad: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-generate c8ceea1 link true /test pull-kubevirt-generate
pull-kubevirt-verify-go-mod c8ceea1 link true /test pull-kubevirt-verify-go-mod
pull-kubevirt-prom-rules-verify c8ceea1 link true /test pull-kubevirt-prom-rules-verify
pull-kubevirt-code-lint c8ceea1 link true /test pull-kubevirt-code-lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@assafad assafad marked this pull request as draft April 10, 2024 11:36
@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 10, 2024
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. area/monitoring dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/buildsystem Denotes an issue or PR that relates to changes in the build system. sig/scale size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants