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

Add VirtualMachineCRCErrors alert #663

Merged

Conversation

machadovilaca
Copy link
Member

What this PR does / why we need it:

Following the initial work made in kubevirt/kubevirt#9741 and kubevirt/containerized-data-importer#2835, we need a way to alert users when they are using RBD volumes with VMs without the krbd:rxbounce option enabled because they may lose data and face severe performance degradation in the cluster.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Release note:

Add VirtualMachineCRCErrors alert

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Aug 17, 2023
@dominikholler
Copy link
Contributor

The ssp-operator is an "Operator that deploys additional KubeVirt resources". Does this PR fit to this expectation?

@0xFelix
Copy link
Member

0xFelix commented Aug 21, 2023

/hold Please let us discuss the necessity for this first.

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 21, 2023
Copy link
Contributor

@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.

Missing some SSP context but the PR looks great!

@@ -164,6 +164,22 @@ func getAlertRules() ([]promv1.Rule, error) {
componentAlertLabelKey: componentAlertLabelValue,
},
},
{
Alert: "VirtualMachineCRCErrors",
Expr: intstr.FromString("kubevirt_ssp_vm_rbd_volume{volume_mode=\"Block\", rxbounce_enabled=\"false\"} > 0"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the issue specific to Block PVCs?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

adding source here for future ref kubevirt/kubevirt#9741 (comment)


func (r *VmReconciler) setupController(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named("vm-controller").
Copy link
Contributor

Choose a reason for hiding this comment

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

vmControllerName

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

}
pvc, err := r.getPVC(vm, volume.PersistentVolumeClaim.ClaimName)
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are better off requeueing in case of HTTP errors, we don't want to just lose that piece of information

Copy link
Member Author

Choose a reason for hiding this comment

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

and adding it to a list of errors, and continuing

}
pv, err := r.getPV(vm, pvc)
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above about requeueing

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

@machadovilaca machadovilaca force-pushed the add-VirtualMachineCRCErrors-alert branch from 58e061b to ffe6c8a Compare August 22, 2023 10:57
@github-actions
Copy link

/cc sradco

@github-actions
Copy link

/cc sradco

Copy link
Contributor

@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.

A couple of small concerns, but the controller makes sense to me

go.mod Outdated
@@ -6,15 +6,17 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/fsnotify/fsnotify v1.6.0
github.com/go-logr/logr v1.2.4
github.com/hashicorp/go-multierror v1.1.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I think libraries will maintain MPL-2.0, only tools like terraform and vault will be under a Business Source License

Copy link
Contributor

Choose a reason for hiding this comment

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

ack

@@ -164,6 +164,22 @@ func getAlertRules() ([]promv1.Rule, error) {
componentAlertLabelKey: componentAlertLabelValue,
},
},
{
Alert: "VirtualMachineCRCErrors",
Expr: intstr.FromString("kubevirt_ssp_vm_rbd_volume{volume_mode=\"Block\", rxbounce_enabled=\"false\"} > 0"),
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need or vector(0) or will this eval just fine?

Copy link
Member Author

Choose a reason for hiding this comment

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

this should be fine, no further actions are taken on the results of kubevirt_ssp_vm_rbd_volume

return fmt.Errorf("alert %s found", alertName)
}, env.Timeout(), time.Second).ShouldNot(HaveOccurred())

Consistently(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@akalenyu
Copy link
Contributor

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2023
internal/operands/metrics/resources.go Outdated Show resolved Hide resolved
@@ -26,6 +26,7 @@ COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/
COPY pkg/ pkg/
Copy link
Member

Choose a reason for hiding this comment

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

Can you place the controller in the internal path instead?

Copy link
Member Author

@machadovilaca machadovilaca Aug 25, 2023

Choose a reason for hiding this comment

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

this is for the metrics, and not for the controller. But following kubevirt/community#219, we want to stay consistent in terms of monitoring between all KubeVirt components

controllers/vm_controller.go Show resolved Hide resolved
controllers/vm_controller.go Outdated Show resolved Hide resolved
controllers/vm_controller.go Outdated Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics.go Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics_test.go Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics.go Outdated Show resolved Hide resolved
controllers/vm_controller.go Show resolved Hide resolved
}

func alertShouldNotBeActive(alertName string) {
Eventually(func() error {
Copy link
Member

Choose a reason for hiding this comment

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

Can this Eventually be dropped and be replaced with the Consistently after?

Copy link
Member Author

Choose a reason for hiding this comment

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

not really, Consistently would not wait for the alert to disappear and would exit with error immediately

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2023
@github-actions
Copy link

/cc sradco

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 28, 2023
@lyarwood
Copy link
Member

/approve

Several nits and supernits that can be fixed in a follow up once this lands in main but overall looks good enough to me.

@akrejcir @ksimon1 would either of you have time today to look at this and get it over the line while Felix is out?

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lyarwood

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 Aug 29, 2023
pkg/monitoring/metrics/rbd_metrics_test.go Outdated Show resolved Hide resolved
internal/common/scheme.go Outdated Show resolved Hide resolved
}

mounter, rxbounceEnabled := getAttributes(pv)
if mounter != "" && mounter != "rbd" {
Copy link
Member

Choose a reason for hiding this comment

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

nit - why check for ""?

Copy link
Member Author

Choose a reason for hiding this comment

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

if no value is set, the storage class defaults to rbd mounter

pkg/monitoring/metrics/metrics.go Outdated Show resolved Hide resolved
verbs:
- get
- list
- watch
Copy link
Member

Choose a reason for hiding this comment

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

nit - appreciate they are all pretty much the same but do we need list and watch here?

Copy link
Contributor

Choose a reason for hiding this comment

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

So the ctrl runtime client will attempt to cache anything you GET once,
and for that, you need list and watch:
https://sdk.operatorframework.io/docs/faqs/#after-deploying-my-operator-i-see-errors-like-failed-to-watch-external-type

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

Copy link
Member

Choose a reason for hiding this comment

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

Ah apologies of course!

controllers/vm_controller.go Outdated Show resolved Hide resolved
@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2023
@lyarwood
Copy link
Member

/lgtm cancel

Gah, github is such a useless platform sometimes.

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2023
Copy link
Collaborator

@akrejcir akrejcir left a comment

Choose a reason for hiding this comment

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

I have mostly code style comments. Otherwise it looks good.

Can you add text to the commit messages explaining why the change is done?

tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
controllers/vm_controller.go Outdated Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics.go Outdated Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics.go Outdated Show resolved Hide resolved
pkg/monitoring/metrics/rbd_metrics_test.go Outdated Show resolved Hide resolved
pkg/monitoring/metrics/metrics_suite_test.go Show resolved Hide resolved
@machadovilaca machadovilaca force-pushed the add-VirtualMachineCRCErrors-alert branch from af7c9b5 to 447c74d Compare August 29, 2023 17:42
@github-actions
Copy link

/cc sradco

@machadovilaca machadovilaca force-pushed the add-VirtualMachineCRCErrors-alert branch from 447c74d to 134b92d Compare August 29, 2023 17:52
@github-actions
Copy link

/cc sradco

@machadovilaca machadovilaca force-pushed the add-VirtualMachineCRCErrors-alert branch from 134b92d to f9a4cd5 Compare August 30, 2023 09:29
@github-actions
Copy link

/cc sradco

@akrejcir
Copy link
Collaborator

Thanks!

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2023
@lyarwood
Copy link
Member

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 30, 2023
@machadovilaca machadovilaca force-pushed the add-VirtualMachineCRCErrors-alert branch from f9a4cd5 to d138f6e Compare August 30, 2023 10:45
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2023
@github-actions
Copy link

/cc sradco

@sonarcloud
Copy link

sonarcloud bot commented Aug 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
1.1% 1.1% Duplication

@machadovilaca
Copy link
Member Author

Had to rebase due to some conflicts with a recent merged PR, on the RBAC related files

@akrejcir
Copy link
Collaborator

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2023
@kubevirt-bot kubevirt-bot merged commit 0b32d61 into kubevirt:main Aug 30, 2023
5 checks passed
@machadovilaca machadovilaca deleted the add-VirtualMachineCRCErrors-alert branch August 30, 2023 12:37
@akrejcir
Copy link
Collaborator

Should this be backported?

@machadovilaca
Copy link
Member Author

yes, we should backport to release-v0.18

@machadovilaca
Copy link
Member Author

/cherry-pick release-v0.18

@kubevirt-bot
Copy link
Contributor

@machadovilaca: #663 failed to apply on top of branch "release-v0.18":

Applying: Add controller for kubevirt_ssp_vm_rbd_volume metrics
Using index info to reconstruct a base tree...
M	Makefile
M	config/rbac/role.yaml
M	controllers/setup.go
M	data/olm-catalog/ssp-operator.clusterserviceversion.yaml
M	docs/development.md
M	go.mod
M	go.sum
M	vendor/modules.txt
Falling back to patching base and 3-way merge...
Auto-merging vendor/modules.txt
CONFLICT (content): Merge conflict in vendor/modules.txt
Auto-merging go.sum
CONFLICT (content): Merge conflict in go.sum
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
Auto-merging docs/development.md
CONFLICT (content): Merge conflict in docs/development.md
Auto-merging data/olm-catalog/ssp-operator.clusterserviceversion.yaml
CONFLICT (content): Merge conflict in data/olm-catalog/ssp-operator.clusterserviceversion.yaml
Auto-merging controllers/setup.go
Auto-merging config/rbac/role.yaml
CONFLICT (content): Merge conflict in config/rbac/role.yaml
Auto-merging Makefile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add controller for kubevirt_ssp_vm_rbd_volume metrics
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-v0.18

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.

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 Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants