Files
octavia/elements/amphora-agent/install.d/amphora-agent-source-install/75-amphora-agent-install
Michael Johnson 7d6322ae08 Switch back to using git for the agent ref
A diskimage-builder patch [1] broke our amphora-agent element by
uninstalling git prior to the post-install.d phase.
A followup patch in Octavia [2] changed how we get the git
reference to awking an git internal log file. This seems fragile
to me, so I am proposing this alternative.
This patch updates our element to finish using git before the
install.d phase is complete.

[1] https://review.opendev.org/745678
[2] https://review.opendev.org/745683

Change-Id: I9a346b626f852171ec00d2868ccb6f98b1fb8994
2020-08-18 11:27:51 -07:00

56 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
SCRIPTDIR=$(dirname $0)
AMP_VENV=/opt/amphora-agent-venv
# Create a virtual environment to contain the amphora agent
${DIB_PYTHON} -m virtualenv $AMP_VENV
$AMP_VENV/bin/pip install pip --upgrade
$AMP_VENV/bin/pip install -U -c /opt/upper-constraints.txt /opt/amphora-agent
# Let's capture the git reference we installed in the venv
git --git-dir=/opt/amphora-agent/.git rev-parse HEAD >> /opt/amphora-agent.gitref
# Workaround https://github.com/svinota/pyroute2/issues/724
# TODO(johnsom) Remove once a that is resolved and 0.5.13 has been blocked in
# global requirements.
$AMP_VENV/bin/pip uninstall -y pyroute2
$AMP_VENV/bin/pip install pyroute2==0.5.12
# Link the amphora-agent out to /usr/local/bin where the startup scripts look
ln -s $AMP_VENV/bin/amphora-agent /usr/local/bin/amphora-agent || true
# Also link out the vrrp check script(s) so they're in PATH for keepalived
ln -s $AMP_VENV/bin/haproxy-vrrp-* /usr/local/bin/ || true
mkdir /etc/octavia
# we assume certs, etc will come in through the config drive
mkdir /etc/octavia/certs
mkdir -p /var/lib/octavia
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.logrotate /etc/logrotate.d/amphora-agent
case "$DIB_INIT_SYSTEM" in
upstart)
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.conf /etc/init/amphora-agent.conf
;;
systemd)
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.service /usr/lib/systemd/system/amphora-agent.service
;;
sysv)
install -D -g root -o root -m 0644 ${SCRIPTDIR}/amphora-agent.init /etc/init.d/amphora-agent.init
;;
*)
echo "Unsupported init system"
exit 1
;;
esac