Bamboo elastic agent instance fails to start with the startup script

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Bamboo elastic agents allows us to configure an instance start-up script at Bamboo Administration > Overview > Image Configurations > Edit. This script is executed when the EC2 instance starts. This document talks about how to troubleshoot issues if the Bamboo elastic agent instance startup script fails to start.

Environment

Issues seen in Bamboo 7.2.4 with Amazon EC2 instance.

Diagnosis

Instance startup script is not tied to the agent. The script is triggered while starting up the AWS EC2 instance. Hence we need to check the AWS EC2 instance logs to understand why the script isn't working.

The AWS EC2 instance logs can be found in:

  1. the Amazon EC2 console section inside the instance page in Bamboo
  2. 
the Amazon EC2 console in AWS
  3. 
directly inside the EC2 instance.

When the EC2 instance starts the first script to run would be runStartupScript.sh. The script is triggered while starting up the AWS EC2 instance.

In the EC2 instance logs, we should look for "BambooStartupScript" to determine whether the script ran fine or not and what is the exit code for the script.

If the script runs we can determine the same by observing the below in the logs. We will see something like this in the EC2 instance logs (in this case the runStartupScript.sh completed with error -exit code 1)

[ 41.191667] cloud-init[1070]: Script /tmp/BambooStartupScript-1.sh exited with status code: 1
[ 41.205565] cloud-init[1070]: Script body:
[ 41.210425] cloud-init[1070]: exit 1

If you don't find the "BambooStartupScript" in the logs means the startup script has not triggered.

Cause

The script fails since it is unable to substitute the absolute path for the variable "bambooAgentBin" in the below line of the script runStartupScript.sh

java -cp $bambooAgentBin/*installer.jar com.atlassian.bamboo.agent.elastic.startup.RunStartupScripts 2>&1 | tee -a /tmp/BambooStartupLog.log*

Solution

  1. Use an approved/listed correct Atlassian AMI ID's for a custom AWS image. To automatically find the correct AMI IDs for the  Bamboo version, we can refer to the   https://confluence.atlassian.com/bamkb/list-of-atlassian-ami-ids-744721326.html documentation.

  2. If you are not using one of the listed Atlassian AMI ID's, then the workaround would be to edit the custom image so that the /etc/rc.d/rc.local file contains the below complete path that automatically starts startup script during the instance initialisation.

          If we replace the variable "bambooAgentBin" with the absolute path (Bamboo agent home path) we see the script runs fine without any errors.

java -cp /opt/bamboo-elastic-agent/bin/atlassian-bamboo-agent-elastic-installer.jar com.atlassian.bamboo.agent.elastic.startup.RunStartupScripts 2>&1 | tee -a /tmp/BambooStartupLog.log
Last modified on Apr 5, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.