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

bmclib version 2 #280

Closed
wants to merge 13 commits into from
Closed

bmclib version 2 #280

wants to merge 13 commits into from

Conversation

joelrebel
Copy link
Member

@joelrebel joelrebel commented Jun 17, 2022

This version is where all features and fixes for the newer client interface methods are to be implemented going ahead.

Clients are to import this version as github.com/bmc-toolbox/bmclib/v2.

I'm looking for suggestions on if this should be a separate v2 branch instead of a directory.

The older interface methods will continue to be maintained as is.

The only difference as of now with the previous bmclib release
is that the Device object type returned by the Inventory() methods are
of the github.com/bmc-toolbox/common.Device type.

This version is where are features and fixes are to be implemented going ahead.

The only difference as of now with the previous bmclib release
is that the Device object type returned by the Inventory() methods are
of the github.com/bmc-toolbox/common.Device type.
@codecov
Copy link

codecov bot commented Jun 17, 2022

Codecov Report

Merging #280 (ba4c8c3) into master (06ad9d6) will increase coverage by 18.49%.
The diff coverage is 75.55%.

❗ Current head ba4c8c3 differs from pull request most recent head fb7d32a. Consider uploading reports for the commit fb7d32a to get more accurate results

@@             Coverage Diff             @@
##           master     #280       +/-   ##
===========================================
+ Coverage   23.88%   42.37%   +18.49%     
===========================================
  Files          70       26       -44     
  Lines       11457     2329     -9128     
===========================================
- Hits         2736      987     -1749     
+ Misses       8126     1221     -6905     
+ Partials      595      121      -474     
Impacted Files Coverage Δ
bmc/firmware.go 95.00% <ø> (ø)
bmc/postcode.go 95.00% <ø> (ø)
client.go 0.00% <0.00%> (ø)
providers/asrockrack/asrockrack.go 44.89% <0.00%> (ø)
providers/asrockrack/firmware.go 10.18% <0.00%> (ø)
providers/asrockrack/helpers.go 47.58% <ø> (ø)
providers/asrockrack/power.go 0.00% <ø> (ø)
providers/asrockrack/user.go 85.89% <ø> (ø)
providers/ipmitool/ipmitool.go 0.00% <ø> (ø)
providers/redfish/firmware.go 43.44% <ø> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06ad9d6...fb7d32a. Read the comment docs.

@jacobweinstock
Copy link
Member

Hey @joelrebel , curious if there are some specific challenges with the current code structure this is seeking to solve? I don't believe versioning changes with this new code structure, right?

@joelrebel
Copy link
Member Author

joelrebel commented Jun 22, 2022

Hey @jacobweinstock, thanks for taking a look, theres a few reasons for the suggested v2, since raising this PR, I realize a branch v2 is recommended over a directory v2.

The thought process behind the v2 is,

  • The older ScanAndConnect and related interfaces will stay in maintenance mode, imported by clients as github.com/bmc-toolbox/bmclib
  • The newer client and related interfaces gets new hardware support and features, the v2 release will not include the older client and interface methods, imported by clients as github.com/bmc-toolbox/bmclib/v2

At the moment, theres one breaking change to the newer client Inventory() methods, where the device object returned
is now of the common.Device type.

Apart from the this,

a. I'd like bmclib to have one client interface that clients can use (instead of two) v2 gives us that way ahead.

b. The older interface methods get pretty much zero new hardware support and have limited maintenance being done. Its hardware compatibility with older interface methods is questionable, from what I see, a lot of the older interface methods do not work with newer Dells and Supermicros, and so I'd like to get rid of code that is not in use.

d. I'd like to also add support for newer hardware without wading through all the cruft of the older unmaintained codebase and working around conflicts in the method and variable names - which shows up when I'm adding new hardware support for the newer client.

c. In v2 the newer client methods can also be adapted to use Go Generics, reducing quite a bit of boilerplate code there.

The choice of v2 as the branch name - given that there is no v1 is because Go expects a major version release that is not on the master branch to be v2 and higher, along with the idea is that clients explicitly import github.com/bmc-toolbox/bmclib/v2 so that they do not end up upgrading by mistake.

bmclib should have been tagged a v1.x.x a while ago, but we have been conservative in the tagging and so I'm inclined to jump straight to v2 with these set of changes.

@jacobweinstock
Copy link
Member

jacobweinstock commented Jun 22, 2022

This is great! Thanks for sharing this reasoning.

What makes you say a v2 branch is preferred over a v2 directory? From this post, I believe the v2 directory is preferred, no?

@joelrebel
Copy link
Member Author

Based on what I understood from https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
having the v2.*.* tags on a separate v2 branch reduces confusion to some extent.

The other reason was that a v2 directory would require separate CI, linter related configuration while they sit on the same branch. I'm still open to a v2 directory if that makes more sense/is easier to work with in this case.

@chrisdoherty4
Copy link
Collaborator

chrisdoherty4 commented Jul 5, 2022

FWIW, I advocate branches over sub-directories as I've found it much easier to maintain over a sub-directory with respect to how Go modules work and git workflows like cherry-picking fixes.

Copy link
Collaborator

@mmlb mmlb left a comment

Choose a reason for hiding this comment

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

I only made it about 1/3 of the way so far but now I'm off for a while so might as well add what I've got.

v2/bmc/boot_device.go Outdated Show resolved Hide resolved
v2/bmc/boot_device.go Outdated Show resolved Hide resolved
v2/bmc/boot_device.go Outdated Show resolved Hide resolved
}

// FirmwareInstallStatusFromInterfaces pass through to library function
func FirmwareInstallStatusFromInterfaces(ctx context.Context, installVersion, component, taskID string, generic []interface{}) (status string, metadata Metadata, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why take genereic []interface{} instead of []FirmwareInstallVerified?

Copy link
Member Author

Choose a reason for hiding this comment

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

The method is invoked with GetDriverInterfaces which returns various interfaces that may or may not implement the FirmwareInstallVerfier interface.


"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"

Copy link
Collaborator

Choose a reason for hiding this comment

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

remove the empty line?

v2/bmc/power.go Outdated
Comment on lines 21 to 22
// "reset": soft down and then power on. simulates a reboot from the host OS.
// "cycle": hard power down followed by a power on. simulates pressing a power button
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be nice to specify what happens if the machine is already powered off when these come in

v2/bmc/power.go Outdated Show resolved Hide resolved
v2/bmc/power.go Outdated Show resolved Hide resolved
v2/bmc/power.go Outdated Show resolved Hide resolved
v2/bmc/user.go Outdated Show resolved Hide resolved
@joelrebel
Copy link
Member Author

Thanks for all the comments and suggestions here, they have been incorporated into the latest set of commits.
The v2 code base is now smaller and cleaner which should allow quicker addition of new features and fixes.

Since all of this code is currently functional and running in production, I'm going to leave the remaining suggestions as is, with issues added for some.

I'll now close this PR since the base branch is master. The PR branch v2 will stay and be tagged with v2.0.0.

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.

4 participants