Skip to content

Eliminate need for "empty" provisioner#820

Merged
metal3-io-bot merged 3 commits intometal3-io:masterfrom
zaneb:empty-provisioner
Mar 29, 2021
Merged

Eliminate need for "empty" provisioner#820
metal3-io-bot merged 3 commits intometal3-io:masterfrom
zaneb:empty-provisioner

Conversation

@zaneb
Copy link
Copy Markdown
Member

@zaneb zaneb commented Mar 18, 2021

Lazily create the BMCAccess information inside the ironic provisioner when needed for registration, rather than in the factory when creating a Provisioner. This eliminates the need for the empty provisioner workaround introduced in #748 to allow us to update the Host state to Unmanaged without creation of the provisioner failing.

Fixes #819

@metal3-io-bot metal3-io-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 18, 2021
@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Mar 18, 2021

/test-integration

Comment thread controllers/metal3.io/baremetalhost_controller.go Outdated
@zaneb zaneb force-pushed the empty-provisioner branch from 02023d3 to 174623b Compare March 23, 2021 14:50
@metal3-io-bot metal3-io-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 23, 2021
@zaneb zaneb changed the title Select empty provisioner in controller Eliminate need for "empty" provisioner Mar 23, 2021
@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Mar 23, 2021

/test-integration

Copy link
Copy Markdown
Member

@andfasano andfasano left a comment

Choose a reason for hiding this comment

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

I like the approach, and I'd suggest to transform p.bmAccess() in a lazy getter to avoid modifying some Provisioner signatures (and still keeping a max single instantiation per loop as before)

@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andfasano, zaneb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Mar 23, 2021

I like the approach, and I'd suggest to transform p.bmAccess() in a lazy getter to avoid modifying some Provisioner signatures (and still keeping a max single instantiation per loop as before)

The only real effect of that would be that you have to copy and paste the error handing to a lot of extra places. NewAccessDetails() doesn't make any network calls, it just parses a URL. We can afford to do that twice in one loop in one particular state without caching the result. None of the public Provisioner method signatures are modified.

@hardys
Copy link
Copy Markdown
Member

hardys commented Mar 24, 2021

This lgtm but now needs a rebase

@andfasano
Copy link
Copy Markdown
Member

The only real effect of that would be that you have to copy and paste the error handing to a lot of extra places. NewAccessDetails() doesn't make any network calls, it just parses a URL. We can afford to do that twice in one loop in one particular state without caching the result. None of the public Provisioner method signatures are modified.

Right, I meant IronicProvisioner private methods that have been changed to accept the bmcCredentials parameters - which make the relationship pretty loosely coupled (surely not a blocking a point, but my preference would be to avoid it).

On a second thought, the current implementation fullfils the requirement expressed in #824 without triggering any error just thanks to the fact that the BMC credentials check have been postponed later into the ValidateManagementAccess (and Prepare), a point that will never be reached for an Unmanaged host without credentials, and there's no comment in the code (or even better a test IINW, as it's also missing from TestMissingBMCParameters) about that.

@zaneb zaneb force-pushed the empty-provisioner branch from 174623b to 41d8966 Compare March 24, 2021 21:33
@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Mar 24, 2021

/test-integration

@hardys
Copy link
Copy Markdown
Member

hardys commented Mar 25, 2021

or even better a test IINW, as it's also missing from TestMissingBMCParameters

I did notice there's no test coverage of the Unmanaged state when I fixed #824 but there wasn't an obvious way to solve it at that point.

With this refactor I guess it's a good time to add such coverage - I'm not blocking on it, but it could be added either in this PR or a followup. @andfasano what are your thoughts?

@andfasano
Copy link
Copy Markdown
Member

With this refactor I guess it's a good time to add such coverage - I'm not blocking on it, but it could be added either in this PR or a followup. @andfasano what are your thoughts?

I think either options would be fine. baremetal_controller_host_test and/or validatemanagementaccess_test/prepare_test could be good candidates for capturing that.

zaneb added 3 commits March 26, 2021 22:08
The empty provisioner is a workaround for the fact that the ironic
provisioner cannot handle instantiation when there are no BMC details
available. The change cadeb28 that
added it also had the effect of logging provisioner information on every
reconcile when it was intended to be logged only once, at startup.

Make it the ironic provisioner factory's responsibility to return an
empty Provisioner at runtime when it cannot create an ironic
Provisioner, and do only one-time startup configuration in main.go.

Fixes metal3-io#819
Not every provisioner operation requires BMC access details, so only
create them when needed. This allows us to reach the unmanaged state
using the ironic provisioner when there are no BMC details specified.

This also means that if the BMC details cannot be parsed correctly,
rather than an error that causes constant requeues and is recorded only
in the logs, we will record a registration failure that will be visible
in the UI.
Now that the ironic provisioner only requires BMC details when
registering (which does not occur in the unmanaged state), remove the
empty provisioner workaround.
@zaneb zaneb force-pushed the empty-provisioner branch from 41d8966 to da3bd7e Compare March 27, 2021 02:10
@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Mar 27, 2021

Now with more unit tests. Thanks for the suggestion @andfasano, in retrospect that was definitely required.
/test-integration

@hardys
Copy link
Copy Markdown
Member

hardys commented Mar 29, 2021

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2021
@metal3-io-bot metal3-io-bot merged commit 04d6151 into metal3-io:master Mar 29, 2021
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excessive logging of provisioner details

4 participants