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

OCPVE-616: fix: add conditions to error on missing lv in case VG is present but thin-pool is not #386

Conversation

jakobmoellerdev
Copy link
Contributor

This adds more failure conditions where the LV could be corrupt and the LVMCluster will now go into degraded state.

Specifically three conditions are created:

  1. If the lvs report of LVM is empty
  2. If the lvs report of LVM is not empty but has no part for any LV
  3. If the lvs report of LVM is not empty but only contains entries for LVs that are not the thin-pool we created.

For all three cases, previously the LVMCluster would remain in "Ready", now it will be "Degraded" instead

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 17, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 17, 2023

@jakobmoellerdev: This pull request references OCPVE-616 which is a valid jira issue.

In response to this:

This adds more failure conditions where the LV could be corrupt and the LVMCluster will now go into degraded state.

Specifically three conditions are created:

  1. If the lvs report of LVM is empty
  2. If the lvs report of LVM is not empty but has no part for any LV
  3. If the lvs report of LVM is not empty but only contains entries for LVs that are not the thin-pool we created.

For all three cases, previously the LVMCluster would remain in "Ready", now it will be "Degraded" instead

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.

@openshift-ci openshift-ci bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 17, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2023

Codecov Report

Merging #386 (e107820) into main (a962b90) will increase coverage by 40.82%.
Report is 26 commits behind head on main.
The diff coverage is 67.34%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #386       +/-   ##
===========================================
+ Coverage   16.59%   57.42%   +40.82%     
===========================================
  Files          24       26        +2     
  Lines        2061     2290      +229     
===========================================
+ Hits          342     1315      +973     
+ Misses       1693      884      -809     
- Partials       26       91       +65     
Files Changed Coverage Δ
controllers/lvmcluster_controller_watches.go 90.32% <ø> (+90.32%) ⬆️
pkg/vgmanager/lvm.go 52.03% <ø> (+4.06%) ⬆️
controllers/topolvm_snapshotclass.go 61.22% <14.28%> (+61.22%) ⬆️
pkg/vgmanager/vgmanager_controller.go 10.40% <48.43%> (+10.40%) ⬆️
controllers/lvmcluster_controller.go 58.63% <50.00%> (+58.63%) ⬆️
pkg/cluster/leaderelection.go 66.66% <66.66%> (ø)
pkg/cluster/sno.go 72.72% <72.72%> (ø)
pkg/vgmanager/devices.go 80.98% <84.21%> (+6.78%) ⬆️
pkg/vgmanager/lv_attr.go 92.59% <92.59%> (ø)
controllers/topolvm_controller.go 94.14% <100.00%> (+94.14%) ⬆️

... and 8 files with indirect coverage changes

@jakobmoellerdev
Copy link
Contributor Author

/test lvm-operator-e2e-aws

Copy link
Contributor

@qJkee qJkee left a comment

Choose a reason for hiding this comment

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

Just this 2 nits, otherwise looks good

@@ -382,12 +382,22 @@ func (r *VGReconciler) validateLVs(volumeGroup *lvmv1alpha1.LVMVolumeGroup) erro
if err != nil {
return fmt.Errorf("could not get logical volumes found inside volume group, volume group content is degraded or corrupt: %w", err)
}
if len(resp.Report) < 1 {
return fmt.Errorf("LV report was empty, meaning that the thin-pool LV is no longer found, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use errors.New() and "`" symbol to avoid concatenation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand why its bad to have concatenation? We never used "`" in the entire Repo and only have 3 cases of errors.New()? Could you explain why thats better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nits inherently don't block merging.

That said, I'm likely to blame for setting a precedent on this type of suggestion. I'm generally quite against concatentation as there's rarely a good case to use it. Happy to explain further but that's probably best done outside of a PR 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

@jakobmoellerdev

  1. Why do we need to concatenate strings when they are not dynamic? Both of them are well known and written by us, so this is a useless job for compiler/runtime

  2. Errorf scans the string for formatting chars like %s and etc. When we know that there is no formatting, why do extra work?
    This is Errorf Implementation
    And this is for errors.New() implementation

Most of the places which are using Errorf actually have formatting symbols


for _, report := range resp.Report {
if len(report.Lv) < 1 {
return fmt.Errorf("no LV was found in the report, meaning that the thin-pool LV is no longer found, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@suleymanakbas91
Copy link
Contributor

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 21, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jakobmoellerdev, suleymanakbas91

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 21, 2023

@jakobmoellerdev: all tests passed!

Full PR test history. Your PR dashboard.

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.

@openshift-merge-robot openshift-merge-robot merged commit 04a7434 into openshift:main Aug 21, 2023
6 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants