Rebuilding a host is not always possible when the host is powered on, particularly when using the bootdisk provisioning method.
A concrete example is VMware vSphere:
When a VM is running, the bootdisk ISO cannot be attached.
This limitation prevents the rebuild process from completing successfully.
Currently, foreman_bootdisk attempts to work around this by automatically restarting the host during ISO attachment. However:
This restart happens without explicit user warning.
This behavior differs from image-based or network-based provisioning, where no implicit reboot is triggered.
The resulting experience is inconsistent and potentially disruptive.
Sometimes, it still fails because of timing when the âBuildâ button is pressed.
Proposal
Disable the âBuildâ button in the UI when:
The host is powered on, and
The selected provisioning method is bootdisk.
This would:
Prevent users from initiating a rebuild that is likely to fail.
Avoid unexpected automatic restarts.
Make the systemâs constraints more transparent and predictable.
Motivation
The goal is not to restrict functionality, but to improve usability and consistency. By preventing an invalid or disruptive workflow at the UI level, we can:
In the old UI when rebuilding a host on a compute resource a checkbox was shown asking for a reboot. I would personally prefer such a behavior if possible as the user will get a concrete warning when trying to use the functionality and can still use it if wanted by checking the box for the additional action. Otherwise he would need to understand why it is not enabled and in which cases it is possible to do a rebuild which gets even more confusing if in a bigger environment you have different ways of provisioning with different restrictions.
This doesnât solve the issue, unfortunately. Attaching the ISO image often did not work because the request was blocked on vmware.
So, the request to start the âBuildâ did already fail. Some time ago, a change in foreman_bootdisk tried to solve the issue by stopping the host first and then attach the iso and then start the host again. From UX this would mean, that the host is suddenly gone.
My proposal is, to disable the âBuildâ button on the Host Details page and add a description that the host needs to be turned off first to set the host in âBuildâ mode.
Like @Dirk said, Foreman has an option to reboot the host when entering build mode:
It may be that the new UI hasnât ported this over, but it should be possible for the user to show the intent to act now. Though Iâm quite sure the orchestration probably never sees this.
IMHO weâre running into limitations of our current orchestration model which is using ActiveRecord hooks instead of proper tasks.
What about the API? Iâd like to see the API respond with a clear error first. For example, return HTTP 422 when the above conditions are met and inhibit the whole save.
IIRC the new UI uses the API to perform that action so that should help when the UI is out of sync with the real power status. For example, when the user turned off the VM and someone/something else turned it on without refreshing the Foreman UI page.
That doesnât block your proposal though it lessens the need for it.