Skip to content

Fix fallback for ironic drivers that don't support soft power off#985

Merged
metal3-io-bot merged 6 commits intometal3-io:masterfrom
zaneb:soft-power-off-fallback
Sep 28, 2021
Merged

Fix fallback for ironic drivers that don't support soft power off#985
metal3-io-bot merged 6 commits intometal3-io:masterfrom
zaneb:soft-power-off-fallback

Conversation

@zaneb
Copy link
Copy Markdown
Member

@zaneb zaneb commented Sep 20, 2021

Fix a regression in #841 that caused ironic drivers that don't support soft power off (such as Fujitsu when the agent is not available) to fail in an infinite loop instead of falling back to a hard power off.

Also clean up the code so it is much less arcane.

Fixes #984

The code to check whether a previous PowerOff command succeeded is
essentially the same between the hard and soft power off modes, so check
it once at the start instead of duplicating it.
If the ironic driver does not support soft power off, we need to fall
back to hard power off. Due to an oversight in
67a27dc we stopped checking for this
and just returned a transient error in this case.

While returning a failure would have resulted in retrying with a hard
power off (albeit after reporting an error to the user), returning a
transient error means that it will retry the soft power off forever.

Restore the fallback and add tests to cover this case. Because we can't
set the dummy ironic server to return different responses on subsequent
calls we will always get an error, so check that it is from the fallback
hard power off.

Fixes metal3-io#984
If we publish the event on success inside changePower, we don't have to
have three different methods calling it that all have to check the
return values for success.

This allows us to eliminate the HostLockedError type.

It also fixes a bug where on Power Off we were publishing an event
saying the power was turned off in the case where we actually were
waiting for a change in the provisioning state.
This is only used for internal flow control, so there is no need to
export it from the package. Given that it is the only thing left in the
errors.go file, it's also better to define it where it is used.
Since we are already using errors.As() to detect
softPowerOffUnsupported, avoid duplicating code by wrapping the error.
@zaneb zaneb requested review from dtantsur and sadasu September 20, 2021 20:13
@metal3-io-bot metal3-io-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 20, 2021
@zaneb
Copy link
Copy Markdown
Member Author

zaneb commented Sep 20, 2021

/test-integration

@hardys
Copy link
Copy Markdown
Member

hardys commented Sep 22, 2021

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2021
@hardys
Copy link
Copy Markdown
Member

hardys commented Sep 27, 2021

/cc @andfasano @fmuyassarov

Copy link
Copy Markdown
Member

@sadasu sadasu left a comment

Choose a reason for hiding this comment

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

/lgtm

I see the regression in the previous changes. Thanks for the fix.

@metal3-io-bot
Copy link
Copy Markdown
Contributor

@sadasu: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

/lgtm

I see the regression in the previous changes. Thanks for the fix.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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.

/approve

t.Fatalf("could not create provisioner: %s", err)
}

_, err = prov.PowerOff(metal3v1alpha1.RebootModeSoft, false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unfortunately the current mock server does not allow to specify multiple, different responses for the same API call, so I don't think there is an easy way currently to test such scenario without enhancing properly the mock (right now, when a response call is configured, like here in .WithNodeStatesPowerUpdate(nodeUUID, http.StatusBadRequest) for example, the mock server will always provide the same answer for all the requests).
I think we could discuss this change in a separate PR as it may be useful also for other tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree that would be a helpful feature to have in the mocks. If that were possible then this could have been implemented in TestPowerOff (and the regression would not have happened) without having to write this separate TestSoftPowerOffFallback test with its own logic.

@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andfasano

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

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 28, 2021
@metal3-io-bot metal3-io-bot merged commit 2abb8f3 into metal3-io:master Sep 28, 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.

Power off fails for drivers that don't support Soft power off

5 participants