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 per provider config: #326

Merged
merged 21 commits into from
May 11, 2023
Merged

Conversation

jacobweinstock
Copy link
Member

@jacobweinstock jacobweinstock commented Apr 30, 2023

What does this PR implement/change/remove?

There exists some config that cannot be shared across all providers. For example, the port for ipmitool is generally 623 but is generally 16992 for intelAMT, cipher suites for ipmitool, or TLS certificates. Allowing per-provider config enables customizing this type of data.

This introduces a * breaking change * to bmclib.NewClient. It no longer takes in a port. The ports for each provider have a default defined and each one can be overridden with a functional option. WithIpmitoolPort, for example.

I think fundamentally the behavior from the consumer side doesn't change. Consumers will still use With functions to specify per provider config. This change just organizes it differently under the hood.

Checklist

  • Tests added
  • Similar commits squashed

The HW vendor this change applies to (if applicable)

The HW model number, product name this change applies to (if applicable)

The BMC firmware and/or BIOS versions that this change applies to (if applicable)

What version of tooling - vendor specific or opensource does this change depend on (if applicable)

Description for changelog/release notes

@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Patch coverage: 44.82% and project coverage change: -0.41 ⚠️

Comparison is base (00e7ccb) 44.55% compared to head (46acd6e) 44.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #326      +/-   ##
==========================================
- Coverage   44.55%   44.14%   -0.41%     
==========================================
  Files          36       37       +1     
  Lines        2790     2904     +114     
==========================================
+ Hits         1243     1282      +39     
- Misses       1422     1494      +72     
- Partials      125      128       +3     
Impacted Files Coverage Δ
bmc/reset.go 94.59% <ø> (ø)
internal/redfishwrapper/client.go 22.22% <0.00%> (ø)
providers/ipmitool/ipmitool.go 0.00% <0.00%> (ø)
option.go 23.91% <23.91%> (ø)
providers/intelamt/intelamt.go 84.05% <50.00%> (-15.95%) ⬇️
providers/redfish/redfish.go 25.55% <50.00%> (+8.36%) ⬆️
providers/asrockrack/asrockrack.go 44.89% <71.42%> (ø)
client.go 55.88% <90.19%> (+5.88%) ⬆️
internal/httpclient/httpclient.go 88.57% <100.00%> (+4.78%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

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

Thanks for the efforts here, left a question/comment inline..

redfishVersionsNotCompatible: []string{},
Logger: logr.Discard(),
Registry: registrar.NewRegistry(),
providerConfig: providerConfig{
Copy link
Member

@joelrebel joelrebel May 1, 2023

Choose a reason for hiding this comment

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

Is it possible to have the providerConfig (or have Options) type be exported as a struct/interface by each provider - so the provider specific configuration and http client checks can stay within the respective packages under providers/{asrockrack,redfish..}/ ?

This would keep the client package free from provider specifics.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @joelrebel , thanks for looking at this. I've updated to have all providers define their own config struct and then client.go just collects them into a single struct. Is this more of what you had in mind? Also, this PR is still very much a WIP.

Copy link
Member

Choose a reason for hiding this comment

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

Will take a look thanks!, apologies I missed the WIP/draft label on the PR.

Copy link
Member Author

@jacobweinstock jacobweinstock May 8, 2023

Choose a reason for hiding this comment

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

Hey @joelrebel, this PR should be ready for a proper review whenever you have cycles. Thanks!

There exists some config that cannot be
shared across all providers. For example,
the port for ipmitool is generally 623, but
is generally 16992 for intelAMT. Allowing
per provider config enables customizing this
type of data.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This allows the provider to specify all config it needs.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This makes New functions cleaner.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Add functional arguments for optional Ipmi struct
values. Add additional struct values. Make cipher
suite 3 the first suite tried. 3 is more commonly
used then 17 so most machines will not try with 17 first.
Add debug logging of ipmitool command line options.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
The new function signature does not return
an error.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This uniforms providers to using func args.
Updates the client to work with this.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Fix basic auth test and example.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
The registering of ipmitool provider doesnt
ignore the error when its constructor is called.
This means that systems without ipmitool will see
that the ipmitool provider does not get registered.
Previously it would always be registered.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Allow for a 10 millisecond error of margin.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Previously it was not.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This makes it more flexible and follows the pattern the
other providers are using.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

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

Thanks for all the fixes and changes here 👍 This does make passing parameters to individual providers easier and succinct.
The README requires some updating based on these changes, apart from that I've left a few comments, nothing major.

internal/ipmi/ipmi.go Outdated Show resolved Hide resolved
internal/ipmi/ipmi.go Show resolved Hide resolved
option.go Outdated Show resolved Hide resolved
client.go Show resolved Hide resolved
gofish is an implementation detail that shouldnt
be exposed like this.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Clean up.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Extra precaution for race conditions.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
@jacobweinstock
Copy link
Member Author

Thanks for all the fixes and changes here 👍 This does make passing parameters to individual providers easier and succinct. The README requires some updating based on these changes, apart from that I've left a few comments, nothing major.

Thanks, @joelrebel. Could you point me to the needed changes in the README.md, please? I'm not finding anything specific.

@joelrebel
Copy link
Member

Thanks, @joelrebel. Could you point me to the needed changes in the README.md, please? I'm not finding anything specific.

sure, in the README we have examples with bmclib.NewClient() that currently accept a port as a parameter, which is not required anymore right?

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
@jacobweinstock
Copy link
Member Author

Thanks, @joelrebel. Could you point me to the needed changes in the README.md, please? I'm not finding anything specific.

sure, in the README we have examples with bmclib.NewClient() that currently accept a port as a parameter, which is not required anymore right?

Ahh, yes. thank you. I have updated the readme.

`-race` flag was added to `make test` and requires CGO.
go: -race requires cgo; enable cgo by setting CGO_ENABLED=1

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

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

Thanks for the work here @jacobweinstock

@mergify mergify bot merged commit 5f3cb35 into bmc-toolbox:main May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants