Skip to content
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

fix ci make target for dirs with spaces and netctl for kubeadm #292

Merged
merged 2 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions install/ansible/install_swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ fi

echo "Starting the installer container"
image_name="contiv/install:__CONTIV_INSTALL_VERSION__"
install_mount="-v $(pwd)/install:/install:Z"
ansible_mount="-v $(pwd)/ansible:/ansible:Z"
config_mount="-v $src_conf_path:$container_conf_path:Z"
cache_mount="-v $(pwd)/contiv_cache:/var/contiv_cache:Z"
mounts="$install_mount $ansible_mount $cache_mount $config_mount"
docker run --rm --net=host $mounts $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $cluster_param $v2plugin_param"
mounts[0]="-v"
mounts[1]="$(pwd)/install:/install:Z"
mounts[2]="-v"
mounts[3]="$(pwd)/ansible:/ansible:Z"
mounts[4]="-v"
mounts[5]="$src_conf_path:$container_conf_path:Z"
mounts[6]="-v"
mounts[7]="$(pwd)/contiv_cache:/var/contiv_cache:Z"
docker run --rm --net=host "${mounts[@]}" $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $cluster_param $v2plugin_param"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

14 changes: 11 additions & 3 deletions install/k8s/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,17 @@ echo "Applying contiv installation"
grep -q -F "netmaster" /etc/hosts || echo "$netmaster netmaster" >>/etc/hosts
echo "To customize the installation press Ctrl+C and edit $contiv_yaml."
sleep 5
chmod +x ./netctl
rm -f /usr/bin/netctl
cp ./netctl /usr/bin/

# extract netctl from netplugin container
echo "Extracting netctl from netplugin container"
netplugin_version=$(
sed '/contiv_network_version/!d;s/.*\: \?"\(.*\)".*/\1/' \
install/ansible/env.json)
docker rm netplugin-tmp >/dev/null 2>/dev/null || :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&>? 2>&1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's shorter,can change if the CI fails again

c_id=$(docker create --name netplugin-tmp contiv/netplugin:$netplugin_version)
docker cp ${c_id}:/contiv/bin/netctl /usr/bin
docker rm ${c_id}

# Install Contiv
$kubectl apply -f $contiv_yaml

Expand Down
16 changes: 8 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ v2plugin_version=${CONTIV_V2PLUGIN_VERSION}
# where everything is assembled, always start with a clean dir and clean it up
output_tmp_dir="$(mktemp -d)"
output_dir="${output_tmp_dir}/contiv-${CONTIV_INSTALLER_VERSION}"
mkdir -p ${output_dir}
trap 'rm -rf ${output_tmp_dir}' EXIT
mkdir -p "${output_dir}"
trap 'rm -rf "${output_tmp_dir}"' EXIT

release_dir=release
mkdir -p $release_dir
Expand All @@ -45,7 +45,7 @@ cp -rf scripts/generate-certificate.sh $output_dir/install
chmod +x $output_dir/install/genInventoryFile.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to quote everywhere$output_dir is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output_dir is $(mktemp -d), which wont' have spaces . . unless TMPDIR is set and has spaces, for this PR, assuming it's not set to a dir with spaces

chmod +x $output_dir/install/generate-certificate.sh

cp -a ${CONTIV_ARTIFACT_STAGING}/ansible ${output_dir}/
cp -a "${CONTIV_ARTIFACT_STAGING}/ansible" ${output_dir}/

# Replace versions
files=$(find $output_dir -type f -name "*.yaml" -or -name "*.sh" -or -name "*.json")
Expand Down Expand Up @@ -96,14 +96,14 @@ curl --fail -sL -o $binary_cache/ovs-switch.deb http://mirrors.kernel.org/ubuntu
# Copy the netplugin release into the binary cache for "full" installer
# Netplugin releases built locally based on a branch are named by their SHA,
# but there is a symlink to point to the SHA named tarball by it's branch name
plugin_tball=${CONTIV_ARTIFACT_STAGING}/$CONTIV_NETPLUGIN_TARBALL_NAME
plugin_tball="${CONTIV_ARTIFACT_STAGING}/$CONTIV_NETPLUGIN_TARBALL_NAME"
if [[ -L "${plugin_tball}" ]]; then
# copy the link (so other processes can find the tarball) and the tarball
target_plugin_tball=$(readlink ${plugin_tball})
cp -a ${plugin_tball} ${binary_cache}/
plugin_tball=${CONTIV_ARTIFACT_STAGING}/${target_plugin_tball}
target_plugin_tball="$(readlink "${plugin_tball}")"
cp -a "${plugin_tball}" "${binary_cache}/"
plugin_tball="${CONTIV_ARTIFACT_STAGING}/${target_plugin_tball}"
fi
cp ${plugin_tball} ${binary_cache}/
cp "${plugin_tball}" "${binary_cache}/"

env_file=$output_dir/install/ansible/env.json
sed -i.bak 's#__AUTH_PROXY_LOCAL_INSTALL__#true#g' "$env_file"
Expand Down
8 changes: 4 additions & 4 deletions scripts/download_ansible_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -euo pipefail

ANSIBLE_REPO_DIR=${CONTIV_ARTIFACT_STAGING}/ansible
ANSIBLE_REPO_DIR="${CONTIV_ARTIFACT_STAGING}/ansible"

rm -rf $ANSIBLE_REPO_DIR
rm -rf "$ANSIBLE_REPO_DIR"

mkdir -p $ANSIBLE_REPO_DIR $CONTIV_ARTIFACT_STAGING
mkdir -p "$ANSIBLE_REPO_DIR" "$CONTIV_ARTIFACT_STAGING"

echo downloading ${CONTIV_ANSIBLE_OWNER}/ansible commit: $CONTIV_ANSIBLE_COMMIT
curl --fail -sL https://api.github.com/repos/${CONTIV_ANSIBLE_OWNER}/ansible/tarball/$CONTIV_ANSIBLE_COMMIT \
| tar --strip-components 1 -C $ANSIBLE_REPO_DIR -z -x
| tar --strip-components 1 -C "$ANSIBLE_REPO_DIR" -z -x
8 changes: 4 additions & 4 deletions scripts/prepare_netplugin_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -euxo pipefail

: ${CONTIV_NETPLUGIN_TARBALL_NAME} # check if defined

mkdir -p $CONTIV_ARTIFACT_STAGING
mkdir -p "$CONTIV_ARTIFACT_STAGING"

# check if installer is for a release version of netplugin
if [ -z "${NETPLUGIN_BRANCH:-}" ]; then
Expand All @@ -21,7 +21,7 @@ if [ -z "${NETPLUGIN_BRANCH:-}" ]; then
base_url=https://github.com/contiv/netplugin/releases/download
netplugin_bundle_name=netplugin-$CONTIV_NETPLUGIN_VERSION.tar.bz2
curl -sL ${base_url}/$CONTIV_NETPLUGIN_VERSION/$netplugin_bundle_name \
-o ${CONTIV_ARTIFACT_STAGING}/$netplugin_bundle_name
-o "${CONTIV_ARTIFACT_STAGING}/$netplugin_bundle_name"
exit
fi

Expand All @@ -47,7 +47,7 @@ BUILD_VERSION=${NETPLUGIN_VERSION} make tar

# move the netplugin tarball to the staging directory for the installer
mv netplugin-${NETPLUGIN_VERSION}.tar.bz2 \
${CONTIV_ARTIFACT_STAGING}/
"${CONTIV_ARTIFACT_STAGING}/"
# create a link so other scripts can find the file without knowing the SHA
cd ${CONTIV_ARTIFACT_STAGING}
cd "${CONTIV_ARTIFACT_STAGING}"
ln -sf netplugin-${NETPLUGIN_VERSION}.tar.bz2 $CONTIV_NETPLUGIN_TARBALL_NAME