Skip to content

Commit

Permalink
vagrant: Stop provisioning VM if one step fails
Browse files Browse the repository at this point in the history
Currently, if e.g., the build provisioning step of the development
Vagrant VM fails, vagrant continues with subsequent steps and ultimately
fails to install and start cilium. This commit updates the Vagrantfile
and associated scripts to fail early.

Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno authored and aanm committed Mar 4, 2020
1 parent 7063fa2 commit e35eeba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ END
end

$bootstrap = <<SCRIPT
set -o errexit
set -o nounset
set -o pipefail
echo "----------------------------------------------------------------"
export PATH=/home/vagrant/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Expand All @@ -53,12 +57,20 @@ mv bpf-map /usr/bin
SCRIPT

$build = <<SCRIPT
set -o errexit
set -o nounset
set -o pipefail
export PATH=/home/vagrant/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
~/go/src/github.com/cilium/cilium/common/build.sh
rm -fr ~/go/bin/cilium*
SCRIPT

$install = <<SCRIPT
set -o errexit
set -o nounset
set -o pipefail
sudo -E make -C /home/vagrant/go/src/github.com/cilium/cilium/ install
sudo mkdir -p /etc/sysconfig
Expand Down
13 changes: 11 additions & 2 deletions contrib/vagrant/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ function write_netcfg_header(){
filename="${3}"
cat <<EOF > "${filename}"
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
K8S=${K8S:-}
if [ -n "${K8S}" ]; then
export K8S="1"
fi
Expand Down Expand Up @@ -175,8 +179,9 @@ function write_k8s_header(){
filename="${2}"
cat <<EOF > "${filename}"
#!/usr/bin/env bash
set -e
set -o errexit
set -o nounset
set -o pipefail
# K8s installation
sudo apt-get -y install curl
Expand Down Expand Up @@ -254,6 +259,10 @@ EOF

cat <<EOF > "${filename_2nd_half}"
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# K8s installation 2nd half
k8s_path="/home/vagrant/go/src/github.com/cilium/cilium/contrib/vagrant/scripts"
export IPV6_EXT="${IPV6_EXT}"
Expand Down

0 comments on commit e35eeba

Please sign in to comment.