-
Notifications
You must be signed in to change notification settings - Fork 43
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
Merged
openshift-merge-robot
merged 1 commit into
openshift:main
from
jakobmoellerdev:OCPVE-616-VG-Creation-Fix-Empty-Reports
Aug 21, 2023
Merged
OCPVE-616: fix: add conditions to error on missing lv in case VG is present but thin-pool is not #386
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, " + | ||
"but the volume group might still exist") | ||
} | ||
|
||
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, " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
"but the volume group might still exist") | ||
} | ||
thinPoolExists := false | ||
for _, lv := range report.Lv { | ||
if lv.Name != volumeGroup.Spec.ThinPoolConfig.Name { | ||
continue | ||
} | ||
thinPoolExists = true | ||
lvAttr, err := ParsedLvAttr(lv.LvAttr) | ||
if err != nil { | ||
return fmt.Errorf("could not parse lv_attr from logical volume %s: %w", lv.Name, err) | ||
|
@@ -414,6 +424,9 @@ func (r *VGReconciler) validateLVs(volumeGroup *lvmv1alpha1.LVMVolumeGroup) erro | |
|
||
r.Log.Info("confirmed created logical volume has correct attributes", "lv_attr", lvAttr.String()) | ||
} | ||
if !thinPoolExists { | ||
return fmt.Errorf("the thin-pool LV is no longer present, but the volume group might still exist") | ||
} | ||
} | ||
return nil | ||
} | ||
|
This file contains 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
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.
There was a problem hiding this comment.
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 concatenationThere was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakobmoellerdev
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
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
ImplementationAnd this is for
errors.New()
implementationMost of the places which are using
Errorf
actually have formatting symbols