-
Notifications
You must be signed in to change notification settings - Fork 254
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
🌱 Develop User-Friendly baremetalhost creation for Tilt interface #1483
🌱 Develop User-Friendly baremetalhost creation for Tilt interface #1483
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of nits.
docs/dev-setup.md
Outdated
|
||
After Tilt is up it is possible to make baremetalhosts by pressing a button in the Tilt localhost interface (right upper corner). This button runs the content of file | ||
```sh | ||
tools/bmh_test/create_bmh.sh {NAME} {VBMC_PORT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools/bmh_test/create_bmh.sh {NAME} {VBMC_PORT} | |
tools/bmh_test/create_bmh.sh <NAME> <VBMC_PORT> |
Usually mandatory parameters are marked with <>
and optioanl parameters []
in documentation.
tools/bmh_test/bmo_net.xml
Outdated
<bootp file='http://192.168.222.199:6180/boot.ipxe'/> | ||
</dhcp> | ||
</ip> | ||
</network> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like missing linefeed at the end of file.
|
||
# Clear network | ||
sudo virsh -c qemu:///system net-destroy bmo-test-network | ||
sudo virsh -c qemu:///system net-undefine bmo-test-network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing linefeed at the end of file.
tools/bmh_test/create_bmh.sh
Outdated
@@ -0,0 +1,100 @@ | |||
#!/bin/bash -x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash -x | |
#!/usr/bin/env bash |
If not executed in container, let user decide which bash
he/she wants to use.
You also have set -x
later, it is unnecessary here. Any options are better added as a separate line anyways, as in case of use executing this as bash ./script.sh
, the -x
would not take effect as shebang is not read.
tools/bmh_test/create_bmh.sh
Outdated
# VBMC runing | ||
# ------------------------------------------------------------------------------------------- | ||
|
||
set -xe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set -xe | |
set -eux |
You generally want to use -eux
, ie. also add failing for undefined variables.
If you'd also use pipes |
in the script, you'd also want to add -o pipefail
by default.
|
||
# Install virtinst | ||
sudo apt update | ||
sudo apt install virtinst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo apt install virtinst | |
sudo apt-get -y install virtinst |
Same
virsh -c qemu:///system net-start bmo-test-network | ||
|
||
# Install libvirt clients and daemon system, python3-pip and pip install vbmc | ||
sudo apt-get install libvirt-clients libvirt-daemon-system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo apt-get install libvirt-clients libvirt-daemon-system | |
sudo apt-get -y install libvirt-clients libvirt-daemon-system |
|
||
# Install libvirt clients and daemon system, python3-pip and pip install vbmc | ||
sudo apt-get install libvirt-clients libvirt-daemon-system | ||
sudo apt-get install python3-pip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo apt-get install python3-pip | |
sudo apt-get -y install python3-pip |
This and other apt-get
should be a single line instead of 4.
# Install libvirt clients and daemon system, python3-pip and pip install vbmc | ||
sudo apt-get install libvirt-clients libvirt-daemon-system | ||
sudo apt-get install python3-pip | ||
pip install vbmc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip install vbmc | |
pip install vbmc |
pip installing stuff into the user's environment is not nice. How about creating virtualenv first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this utilizes sudo
many times, consider checking if user is not root, and failing, and documenting it that it needs to be run sudo ./run_local_bmh_test_setup.sh
instead.
The virsh/vbmc code gets copied over and over again. There is metal3-dev-env, there is now code in test/e2e. Could you maybe find a common place, ideally in metal3-dev-env? Maybe split some playbooks out of it? Also, I'd recommend using sushy-tools instead of vbmc. |
I explicitly want to get rid of the need for metal3-dev-env for these things. If it was just providing the VMs and BareMetalHosts fine, but it does way too much, which makes it extremely hard to work with. |
1ce8422
to
993339b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple small nits.
tools/bmh_test/create_bmh.sh
Outdated
# Set default values | ||
NAME="${1:?}" | ||
VBMC_PORT="${2:?}" | ||
CONSUMER="${3}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, now that you have set -u
, this will fail unless $3
and $4
are provided.
You want to have
CONSUMER="${3}" | |
CONSUMER="${3:-}" |
So at least empty value is substituted, which works nicely with the [[ -n ... ]]
which we have later, since it is checking undefined or empty value.
tools/bmh_test/create_bmh.sh
Outdated
NAME="${1:?}" | ||
VBMC_PORT="${2:?}" | ||
CONSUMER="${3}" | ||
CONSUMER_NAMESPACE="${4}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
set -euxo pipefail | ||
|
||
# Check if the script is run as root | ||
if [[ $UID != 0 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if [[ $UID != 0 ]]; then | |
if [[ ${EUID} != 0 ]]; then |
You should be checking effective UID, ${EUID}
as that cannot be faked.
|
||
# Check if the script is run as root | ||
if [[ $UID != 0 ]]; then | ||
echo "This script must be run as root" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "This script must be run as root" | |
echo "ERROR: This script must be run as root" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress @peppi-lotta !
This will make it much more enjoyable to work with BMO once finished 🙂
tools/bmh_test/bmo_net.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reuse hack/e2e/net.xml
instead of adding this?
VM_LIST=$(virsh -c qemu:///system list --all --name) | ||
|
||
# Loop through the list and delete each virtual machine | ||
for vm_name in ${VM_LIST}; do | ||
kubectl delete baremetalhost "${vm_name}" | ||
virsh -c qemu:///system destroy --domain "${vm_name}" | ||
virsh -c qemu:///system undefine --domain "${vm_name}" --remove-all-storage | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too dangerous. We should at least filter the VMs based on some prefix. How about we add a prefix to all created VMs and also mention this in the tilt UI so it is clear? Then we can filter for VMs with that prefix here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try to split this so that we have one script for creating the VM and one for applying the BMH? Then we could reuse the first script in ci-e2e.sh
and save some duplication 🙂
58ccde7
to
26ddbe5
Compare
/test-centos-e2e-integration-main |
/test-ubuntu-integration-main |
A minor comment: This PR currently has 4 commits, but most of them either fix issues from previous ones, or merge another branch onto this one. Maybe consider squashing them all to one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits
|
||
# Install virtinst, libvirt clients and daemon system | ||
apt-get -y update | ||
apt-get -y install virtinst libvirt-clients libvirt-daemon-system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we decided to only support Tilt in Ubuntu/Debian? If so, could you update the README with that information?
Tiltfile
Outdated
icon_name='add_box', | ||
text='Add New baremetalhost', | ||
inputs=[ | ||
text_input('NAME', '"bmh-tes-" is automatically added to the begining of the name. This naming convention is later used to clean the local testing environment.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo. It should be "bmh-test-"
docs/dev-setup.md
Outdated
sudo tools/bmh_test/run_local_bmh_test_setup.sh | ||
``` | ||
|
||
The network, VBMC, virtual vbmc environment and virtual machines can be run down with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo "clean up" might be a better wording than "run down", at least I wouldn't understand that term.
d59909a
to
943d3d0
Compare
/test-centos-e2e-integration-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice progress! I was able to test this locally and it worked! 🎉
A couple of comments below
docs/dev-setup.md
Outdated
tools/bmh_test/create_bmh.sh <NAME> <VBMC_PORT> | ||
``` | ||
|
||
and adds the values given to the button as arguments. Controlplane host can be created with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but was a bit hard to understand I think. Or maybe I am using it wrong. 😅 Could you make it so the drop down where we add the value also has a button for creating?
Current flow:
- drop down and fill in values
- "go back" and press the +
What I was thinking is like in CAPI:
- drop down and fill in values
- below the values press "Create"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to find a way to make this work in the second way. For what I was able to find Tilt doesn't support adding buttons to the drop down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I was confusing myself. It looks different in different places apparently. The button is good 👍
# Check if the script is run as root | ||
if [[ $EUID != 0 ]]; then | ||
echo "ERROR: This script must be run as root" | ||
exit 1 | ||
fi | ||
|
||
# Install virtinst, libvirt clients and daemon system | ||
apt-get -y update | ||
apt-get -y install virtinst libvirt-clients libvirt-daemon-system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather check that virt-install is available end error out if not. So instead of trying to install these things, explain to the developer what is needed and let them set it up as they want.
We can also skip the root requirement then.
93d21fe
to
43e1af8
Compare
/test-ubuntu-integration-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I was able to confirm that this is working nicely now!
Just one nit below
266bb6c
to
925c12c
Compare
Looks like something happened when rebasing so now there are 2 commits 🤔 |
Signed-off-by: peppi-lotta <[email protected]>
925c12c
to
79af5f8
Compare
/test-ubuntu-integration-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
Nits only!
/hold
@@ -174,6 +174,32 @@ refer to | |||
[the development setup guide of CAPM3](https://github.com/metal3-io/cluster-api-provider-metal3/blob/main/docs/dev-setup.md#tilt-for-dev-in-capm3) | |||
and specially the [Baremetal Operator Integration](https://github.com/metal3-io/cluster-api-provider-metal3/blob/main/docs/dev-setup.md#including-baremetal-operator-and-ip-address-manager) | |||
|
|||
### Making (virtual) BareMetalHosts with Tilt interface | |||
|
|||
Virtinst, libvirt-clients, libvirt-daemon-system, and [Virtualbmc](https://pypi.org/project/virtualbmc/) are required to to create BareMetalHosts this way. The network and VBMC needed for making a BareMetalHosts can be initialized with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virtinst, libvirt-clients, libvirt-daemon-system, and [Virtualbmc](https://pypi.org/project/virtualbmc/) are required to to create BareMetalHosts this way. The network and VBMC needed for making a BareMetalHosts can be initialized with | |
Virtinst, libvirt-clients, libvirt-daemon-system, and [Virtualbmc](https://pypi.org/project/virtualbmc/) are required to create BareMetalHosts this way. The network and VBMC needed for making a BareMetalHosts can be initialized with |
tools/bmh_test/create_bmh.sh <NAME> <VBMC_PORT> | ||
``` | ||
|
||
and adds the values given to the button as arguments. Controlplane host can be created with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now forgetting the convention of this but I think we should rather write ControlPlane
instead of Controlplane
but please check it.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kashifest The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@peppi-lotta do you want to fix the nits here or in a follow up? This looks good to merge just need to remove the hold |
I'll do it on a follow up. |
/unhold |
/metal3-bmo-e2e-test |
Signed-off-by: peppi-lotta [email protected]
Tilt improved for easier baremetalhost creation
What this PR does / why we need it:
Fixes #1478