Skip to content

megaraid: Properly handle permanent Path and device Path#20

Merged
TeddyAndrieux merged 1 commit intomainfrom
bugfix/handle-permanent-path
May 12, 2025
Merged

megaraid: Properly handle permanent Path and device Path#20
TeddyAndrieux merged 1 commit intomainfrom
bugfix/handle-permanent-path

Conversation

@TeddyAndrieux
Copy link
Copy Markdown
Contributor

The logic has been moved to domain as it shouldn't depends on the implementation even if it's only used for megaraid for now

@TeddyAndrieux TeddyAndrieux requested a review from a team as a code owner May 7, 2025 16:16
The logic has been moved to domain as it shouldn't depends on the
implementation even if it's only used for megaraid for now
@TeddyAndrieux TeddyAndrieux force-pushed the bugfix/handle-permanent-path branch from 090c8cb to aea8343 Compare May 7, 2025 16:20
// NOTE: For physical drives backed by hardware RAID controllers this might not
// be available.
// nolint: funlen,nestif // This function is pretty simple to follow.
func (pd *PhysicalDrive) ComputePaths() error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WDYT about writing this as 2 methods (permanent and device) that returns the computed values instead of modifying implicitly ?
Better error handling, readability and testability IMO

Copy link
Copy Markdown
Contributor Author

@TeddyAndrieux TeddyAndrieux May 9, 2025

Choose a reason for hiding this comment

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

Since it's a method of physicalDrive struct to me it's cleaner to update in place
For separating permanent and device I could but one depends on the other and in all case we want to compute boths so... I don't know if it brings a lot of value proper error message are handled by this function and not the upper ones

Comment on lines +576 to +581
err = pd.ComputePaths()
if err != nil {
return devicePath, "", errors.Wrap(err, "failed to compute paths from physical drive")
}

return pd.DevicePath, pd.PermanentPath, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cf com above, would make this part less implicity and enable more precise error handling

@TeddyAndrieux TeddyAndrieux merged commit b2e286e into main May 12, 2025
3 checks passed
@TeddyAndrieux TeddyAndrieux deleted the bugfix/handle-permanent-path branch May 12, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants