From 7ffa6bb2e5620d18d6ab3dcb10951f1dc24da128 Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Wed, 22 May 2024 10:09:14 +0100 Subject: [PATCH] Setup parca-agent for ci-runs Start collecting profiling data for ci-runs (specifically looking at longer gating test runs). We want the data for 2 reasons: 1. See if there are any potential bottlenecks in terms of performance that we can see when the jujud and jujud-controller is running. 2. We can use profile guided optimisations (PGO) from the runs to apply to the binaries. This currently only applies to lxd deployments. For other providers we will need to install it via cloud-init or bake it into an image. This is an experiment to see if it's useful or not. --- jobs/ci-run/integration/common/test-runner.sh | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/jobs/ci-run/integration/common/test-runner.sh b/jobs/ci-run/integration/common/test-runner.sh index c1ed72a..4e997a8 100644 --- a/jobs/ci-run/integration/common/test-runner.sh +++ b/jobs/ci-run/integration/common/test-runner.sh @@ -32,6 +32,21 @@ while sudo lsof /var/lib/apt/lists/lock 2> /dev/null; do done sudo apt-get -y update +setup_parca_agent() { + # Parca agent is already installed, then skip it. + if [ "$(which parca-agent >/dev/null 2>&1)" ]; then + return + fi + + sudo snap install parca-agent --classic + sudo snap set parca-agent metadata-external-labels="machine=ci-run-${{BOOTSTRAP_PROVIDER}}" + + # Hide the setting of the bearer token to the parca agent. + set +x + sudo snap set parca-agent remote-store-bearer-token="${{PARCA_BEARER_TOKEN}}" + set -x +} + # Issue around installing a snap within a privileged container on a host # fails. There is no real work around once privileged and nesting has been # set, so retries succeed. @@ -55,8 +70,18 @@ while [ $attempts -lt 3 ]; do if [ ! "$(which microceph >/dev/null 2>&1)" ]; then sudo snap install microceph || true fi - # shellcheck disable=SC2193 - if [ "${{BOOTSTRAP_PROVIDER:-}}" = "ec2" ]; then + + provider="${{BOOTSTRAP_PROVIDER:-}}" + case "$provider" in + "lxd" | "lxd-remote" | "localhost") + setup_parca_agent || true + ;; + *) + echo "Skipping parca-agent setup for provider: $provider" + ;; + esac + + if [ "$provider" = "ec2" ]; then if [ ! "$(which aws >/dev/null 2>&1)" ]; then sudo snap install aws-cli --classic || true fi @@ -72,8 +97,8 @@ while [ $attempts -lt 3 ]; do echo -e "[default]\nregion = us-east-1" > "$HOME"/.aws/config chmod 600 ~/.aws/* fi - # shellcheck disable=SC2193 - if [ "${{BOOTSTRAP_PROVIDER:-}}" = "azure" ]; then + + if [ "$provider" = "azure" ]; then if [ ! "$(which az >/dev/null 2>&1)" ]; then curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash fi