Fixes #39067 - rebuild only if host powered off#10860
Fixes #39067 - rebuild only if host powered off#10860stejskalleos merged 1 commit intotheforeman:developfrom
Conversation
Use theforeman/foreman#10860 and refactor the vsphere/proxmox methods as it is no longer needed to start/stop/reboot
bef0a46 to
85686f8
Compare
stejskalleos
left a comment
There was a problem hiding this comment.
Question: What if Foreman stopped the machine before/during the rebuild action?
What's the point in rebuilding the VM host without rebooting?
Can we break something if we introduce such a behavior?
webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/index.js
Outdated
Show resolved
Hide resolved
| Foreman::Plugin.all.map(&:provision_methods).inject(:merge) || {} | ||
| end | ||
|
|
||
| def rebuild_requires_poweroff |
There was a problem hiding this comment.
I'm not sure that this is the right place for the method.
Should the host model be the one who decides if it needs to be powered off, when it's the compute resource who defines this provisioning method, and therefore should keep this information as well.
Looking at can_be_built?
def can_be_built?
managed? && !image_build? && !build?
endmanaged & build are attrs, and image_build? is a method in managed.rb:
def image_build?
provision_method == 'image'
endIt feels weird to me, I need to think about it.
There was a problem hiding this comment.
this method is used to determine, if the "re-build" method (= press the 'Build' button) requires that the host is powered off.
It will try to ask the used provision_method. So,in case of foreman_bootdisk, https://github.com/theforeman/foreman_bootdisk/pull/180/changes#diff-64bce33ed5907be7299b1be146db9be2a5c5a4d8b5e726187911c3c0ff38ec32R34 this will answer with "true"
So, the behavior can be adjusted for each provision_method in general. IF the host needs to be turned of is then related on the actual state of the host with the UI / react.
|
how can we continue with this @stejskalleos ? |
webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/actions.js
Show resolved
Hide resolved
85686f8 to
9adb425
Compare
9adb425 to
5c39680
Compare
ekohl
left a comment
There was a problem hiding this comment.
The actual changing of a host to build mode happens in PUT /api/v2/hosts/:id:
foreman/app/controllers/api/v2/hosts_controller.rb
Lines 153 to 166 in 1981e78
But perhaps it should be done at the model layer that prevents a save in the first place.
5c39680 to
441f639
Compare
|
f834aac to
f7b5a0e
Compare
f7b5a0e to
34c1af9
Compare
webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/index.js
Outdated
Show resolved
Hide resolved
webpack/assets/javascripts/react_app/components/HostDetails/ActionsBar/index.js
Outdated
Show resolved
Hide resolved
34c1af9 to
8f39a38
Compare
b7404e1 to
4f0eb98
Compare
4f0eb98 to
4e87c24
Compare
|
@stejskalleos ready to merge. |
Working on my test setup, it's on my board for this week. Code LGTM, so if there are no test issues, I think we can merge. |
|
Failed container job is not related to the PR changes, merging. |
|
thanks @sbernhard |
Use theforeman/foreman#10860 and refactor the vsphere/proxmox methods as it is no longer needed to start/stop/reboot

Rebuild a host is sometimes not possibe if the host is powered on.
e.g. there are 2 issues for bootdisk:
Requires theforeman/foreman_bootdisk#180
This is how it currently look like:
