summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
1a9c875)
Make sure a VM image build fails if any step fails. Else we can end up
with a bad image not containing all that we want, and we discover this
later at run time.
For instance, without the current patch, we can get a generator VM image
without nfvbench installed because "pip install" failed, but this is not
detected by the build process because the last step in
post-install.d/52-nfvbench-script is an "echo" command that returns a
success code.
We fix this by making all the Bash scripts fail if any command whose
return code is not tested fails (set -euo pipefail).
Change-Id: Ic5ec9eb85a8d6e7e4d1dcbac8ebcac5931e4808e
Signed-off-by: Gwenael Lambrouin <gwenael.lambrouin@orange.com>
# Ubuntu: sudo apt-get -y install python3 python3-venv qemu-utils kpartx
# CentOS: sudo yum install -y python3 qemu-img kpartx
# Ubuntu: sudo apt-get -y install python3 python3-venv qemu-utils kpartx
# CentOS: sudo yum install -y python3 qemu-img kpartx
+# Stop on error (see https://wizardzines.com/comics/bash-errors/)
+set -euo pipefail
+
usage() {
echo "Usage: $0 [-l] [-g] [-v]"
echo " -l build NFVbench loop VM image"
usage() {
echo "Usage: $0 [-l] [-g] [-v]"
echo " -l build NFVbench loop VM image"
+# Stop on error
+set -euo pipefail
+
grubby --update-kernel=ALL --args="isolcpus=1-7 rcu_nocbs=1 nohz=on nohz_full=1 nmi_watchdog=0"
grubby --update-kernel=ALL --args="default_hugepagesz=1G hugepagesz=1G hugepages=4"
grubby --update-kernel=ALL --args="intel_iommu=on iommu=pt"
grubby --update-kernel=ALL --args="isolcpus=1-7 rcu_nocbs=1 nohz=on nohz_full=1 nmi_watchdog=0"
grubby --update-kernel=ALL --args="default_hugepagesz=1G hugepagesz=1G hugepages=4"
grubby --update-kernel=ALL --args="intel_iommu=on iommu=pt"
+# Stop on error
+set -euo pipefail
+
grubby --update-kernel=ALL --args="vga=792"
grubby --update-kernel=ALL --args="vga=792"
+# Stop on error
+set -euo pipefail
+
grubby --set-default-index=0
grubby --set-default-index=0
+# Stop on error
+set -euo pipefail
+
if [ $DIB_USE_ELREPO_KERNEL != "True" ]; then
exit 0
fi
if [ $DIB_USE_ELREPO_KERNEL != "True" ]; then
exit 0
fi
+# Stop on error
+set -euo pipefail
+
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel pbr
python3 -m pip install pyyaml
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel pbr
python3 -m pip install pyyaml
+# Stop on error
+set -euo pipefail
+
# set accurate rc.local file corresponding to current image built
if [ $DIB_DEV_IMAGE = "loopvm" ]; then
mv /etc/rc.d/rc.local.loopvm /etc/rc.d/rc.local
else
mv /etc/rc.d/rc.local.generator /etc/rc.d/rc.local
# set accurate rc.local file corresponding to current image built
if [ $DIB_DEV_IMAGE = "loopvm" ]; then
mv /etc/rc.d/rc.local.loopvm /etc/rc.d/rc.local
else
mv /etc/rc.d/rc.local.generator /etc/rc.d/rc.local
-fi
\ No newline at end of file
+# Stop on error
+set -euo pipefail
+
chmod +x /etc/rc.d/rc.local
chmod +x /etc/sysconfig/network-scripts/ifcfg-eth0
chmod +x /etc/profile.d/nfvbench.sh
chmod +x /etc/rc.d/rc.local
chmod +x /etc/sysconfig/network-scripts/ifcfg-eth0
chmod +x /etc/profile.d/nfvbench.sh
+# Make sure the disk image build fails if nfvbench installation fails
+set -euo pipefail
+
if [ $DIB_DEV_IMAGE != "generator" ]; then
exit 0
fi
if [ $DIB_DEV_IMAGE != "generator" ]; then
exit 0
fi
+# Stop on error
+set -euo pipefail
+
# Set UseDNS no value in sshd_config to reduce time to connect
# Set UseDNS no value in sshd_config to reduce time to connect
-echo "UseDNS no" >> /etc/ssh/sshd_config
\ No newline at end of file
+echo "UseDNS no" >> /etc/ssh/sshd_config
+# Stop on error
+set -euo pipefail
+
yum erase -y python-devel libyaml-devel numactl-devel kernel-devel kernel-headers kernel-lt-headers kernel-lt-devel gcc git python3-dev libpython3.6-dev
yum erase -y python-devel libyaml-devel numactl-devel kernel-devel kernel-headers kernel-lt-headers kernel-lt-devel gcc git python3-dev libpython3.6-dev