Fedora 17 Elastic Image Minor Problem

I have a small problem with my Fedora 17 OnDemand elastic agent.

I have followed all the instructions on the confluence website and have successfully set up a Fedora 17 elastic bamboo image.

However, I have one minor issue that I cannot get my head around. Hopefully someone with far greater Linux insight can shed some light.

The following line in rc.local does nothing on my Fedora 17 box:

su -c bamboo-elastic-agent - bamboo &

There is some issue with the & doing something wierd. If I remove it and move the ampersand to the /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent script:

java -server -Xms32m -Xmx512m -XX:MaxPermSize=256m -cp $BAMBOO_CLASSPATH com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap 2>&1 | tee -a ~/bamboo-elastic-agent.out &

(Notice it has been added on the end!)

Everything is fine then...

I have tried lots and lots of debugging (4 hours worth) trying to work out why that line doesn't execute correctly in rc.local.

The following line works:

su -c "echo hello > ~/test.log" - bamboo &

it correctly creates the test.log file in the /home/bamboo location. However, if I move the same thing into a script:

/usr/bin/bamboo-test-script:

#!/bin/sh
echo hello

The following line will do nothing:

su -c "bamboo-test-script > ~/test.log" - bamboo &

But the following will work fine:

su -c "bamboo-test-script > ~/test.log" - bamboo

Do you guys have any idea what is going on? This is literally the only thing stopping me from making various distro elastic images :(

4 answers

1 accepted

This is now solved in the newer bamboo agent scripts with OnDemand Bamboo 4.1

Forgot to metion, this is with OnDemand, so using bamboo-elastic-agent-3.0.4

0 votes

Which shell are you using? I.e. what does

ls -l /bin/sh

show?

Also:

#!bin/sh

should be:

#!/bin/sh

Sorry missed out the forward slash. it did have it when i was testing. Fedora uses bash . Thats what /bin/sh is softlinked too.

Does

su -c "bamboo-test-script > ~/test.log" - bamboo </dev/null >/dev/null 2>&1 &

work?

This is literally the only thing stopping me from making various distro elastic images :(

I don't think so ;-)

OK, now try:

su -c bamboo-elastic-agent - bamboo </dev/null >/tmp/bamboo-elastic-agent.out 2>&1 &

Let's see if there was any interesting output

That didn't start up the bamboo agent - but the script ran.

The following

#su -c bamboo-elastic-agent - bamboo &amp;
	su -c "echo matt &gt; ~/matt1.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;
	su -c "echo matt &gt; ~/matt2.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1
	su -c "matt-test &gt; ~/matt3.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;
	su -c "matt-test &gt; ~/matt4.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1
	su -c "matt-test &gt; ~/matt5.log" - bamboo &amp;
	su -c "matt-test &gt; ~/matt6.log" - bamboo 
	su -c "bamboo-test-script &gt; ~/test.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;

Where /usr/bin/matt-test is

[bamboo@localhost ~]$ cat /usr/bin/matt-test &amp;&amp; ls -asl /usr/bin/matt-test 

#!/bin/sh

echo matt

4 -rwxr-xr-x. 1 root root 20 Jun 14 03:50 /usr/bin/matt-test

Creates:

[bamboo@localhost ~]$ ls -asl *.log &amp;&amp; cat *.log &amp;&amp; ps -ef | grep java
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt1.log
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt2.log
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt3.log
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt4.log
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt5.log
4 -rw-rw-r--. 1 bamboo bamboo 5 Jun 14 03:54 matt6.log
0 -rw-rw-r--. 1 bamboo bamboo 0 Jun 14 03:54 test.log
matt
matt
matt
matt
matt
matt
bamboo     879   856  0 03:57 pts/0    00:00:00 grep --color=auto java

This is literally the only thing stopping me from making various distro elastic images :(

I don't think so ;-)

Ha, I can imagine there will be a lot more stumbling blocks along the way ;-)

Thanks, I'll try that in a minute. I can't reproduce the previous post at the moment.

I'm starting up the instance, then rebooting through the EC2 console but no /home/bamboo/test.log at the moment.

That outputs nothing:

[bamboo@localhost ~]$ ls /tmp
bamboo-elastic-agent.out  hsperfdata_root  setupEbsSnapshot.log  setupEphemeralStorageStructure.log  testIfStartedFromBamboo.log  testVersions.log
[bamboo@localhost ~]$ cat /tmp/bamboo-elastic-agent.out

I've noticed something strange. I now have two test files. One is /usr/bin/matt

[root@localhost bamboo]# ls /usr/bin/matt-test -l
-rwxr-xr-x. 1 root root 21 Jun 14 04:33 /usr/bin/matt-test
[root@localhost bamboo]# cat /usr/bin/matt-test 
#!/bin/sh
echo hello

And the other is /opt/bamboo-elastic-agent/bin/bamboo-test-script

[root@localhost bamboo]# ls -l /opt/bamboo-elastic-agent/bin/bamboo-test-script 
-rwxr-xr-x. 1 root root 450 Jun 14 04:31 /opt/bamboo-elastic-agent/bin/bamboo-test-script
[root@localhost bamboo]# cat /opt/bamboo-elastic-agent/bin/bamboo-test-script 
#!/bin/bash
echo Winning...

With the following /etc/rc.d/rc.local

[root@localhost bamboo]# cat /etc/rc.d/rc.local 
#!/bin/sh
[snip]
	#su -c bamboo-elastic-agent - bamboo &amp;
	su -c "echo matt &gt; ~/matt1.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;
	su -c "echo matt &gt; ~/matt2.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 
	su -c "matt-test &gt; ~/matt3.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;
	su -c "matt-test &gt; ~/matt4.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1
	su -c 'set &gt; ~/set.log' - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1
	su -c "bamboo-test-script &gt; ~/test.log" - bamboo &lt;/dev/null &gt;/dev/null 2&gt;&amp;1 &amp;
	su -c bamboo-elastic-agent - bamboo &lt;/dev/null &gt;/tmp/bamboo-elastic-agent.out 2&gt;&amp;1 &amp;
[snip]

The following gets created:

[root@localhost bamboo]# ls &amp;&amp; cat matt?.log
matt1.log  matt2.log  matt3.log  matt4.log  set.log
matt
matt
hello
hello

Note that there is no test.log that should contain "Winning..."

The PATH in set.log is:

PATH=/opt/bamboo-elastic-agent/bin:/opt/ec2-api-tools/bin:/usr/lib/jvm/java-openjdk/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/bamboo/.local/bin:/home/bamboo/bin

Which is correct for the system I am on.

The Fedora image I started with was form here:

http://fedoraproject.org/wiki/Cloud_images

They are very minimal images, could I be missing something that might be needed in the scripts?

Hmm, try using an absolute path when staring the bamboo startup script and put something like touch /tmp/asd as the first line of that script to see whether it runs at all.

I added the follow to /etc/rc.d/rc.local:

su -c /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent - bamboo &lt;/dev/null &gt;/tmp/bamboo-elastic-agent.out 2&gt;&amp;1 &amp;

And the following

[root@ip-10-243-149-134 bamboo]# cat /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent 
#!/bin/bash
touch /tmp/bamboo-elastic-agent-script-ran
trap "exit" ERR
[snip]

And /tmp looks like this:

[bamboo@ip-10-190-95-16 ~]$ ls /tmp/
checkElasticAgent.log  hsperfdata_root  setupEbsSnapshot.log  setupEphemeralStorageStructure.log  testIfStartedFromBamboo.log  testVersions.log

I am so confused how that line isn't doing anything in rc.local... :'-(

I noticed that Fedora 17 doesn't have /etc/init.d/crond:

[root@ip-10-243-149-134 bamboo]# ls /etc/init.d/ -asl
total 40
 4 drwxr-xr-x.  2 root root  4096 May 16 19:57 .
 4 drwxr-xr-x. 10 root root  4096 Jun 14 07:44 ..
20 -rw-r--r--.  1 root root 19914 Mar 16 10:26 functions
 4 -rwxr-xr-x.  1 root root  2989 Mar 16 10:26 netconsole
 8 -rwxr-xr-x.  1 root root  7199 Mar 16 10:26 network
But I have the service:
[root@ip-10-243-149-134 bamboo]# /sbin/service crond status
Redirecting to /bin/systemctl  status crond.service
crond.service - Command Scheduler
	  Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled)
	  Active: active (running) since Thu, 14 Jun 2012 07:37:52 -0400; 11min ago
	Main PID: 343 (crond)
	  CGroup: name=systemd:/system/crond.service
		  └ 343 /usr/sbin/crond -n

Jun 14 07:37:53 localhost.localdomain /usr/sbin/crond[343]: (CRON) INFO (running with inotify support)
Also I can boot the AMI in the EC2 console and it doesn't terminate, so the following in /etc/rc.d/rc.local should run.
else
	echo "This instance will be shut down immediately."
	/sbin/telinit -t 0 0
fi

The following are a temporary workaround (for anyone reading this at a later date):

[bamboo@localhost ~]$ cat /etc/rc.d/rc.local 
#!/bin/sh
/opt/bamboo-elastic-agent/bin/testIfStartedFromBamboo.sh &gt;/tmp/testIfStartedFromBamboo.log 2&gt;&amp;1
if [ $? -eq 0 ]; then
	/opt/bamboo-elastic-agent/bin/setupEphemeralStorageStructure.sh &gt;&gt; /tmp/setupEphemeralStorageStructure.log
	/opt/bamboo-elastic-agent/bin/restoreEbsSnapshotFromUserData.sh &gt;&gt; /tmp/setupEbsSnapshot.log
	/opt/bamboo-elastic-agent/bin/testVersions.sh &gt;/tmp/testVersions.log 2&gt;&amp;1
	if [ $? -eq 0 ]; then
# matt.clarkson@gmail.com
# Usually the following line is used for the bamboo elastic agent.
# However, using the ampersand does not let the script run on F17
# We have moved the ampersand into the script
# There is a thread going with Atlassian for a fix:
# https://answers.atlassian.com/questions/61970/fedora-17-elastic-image-minor-problem
#		su -c bamboo-elastic-agent - bamboo &amp;
		su -c bamboo-elastic-agent - bamboo
	else
		echo "Bamboo agent not started..."        
	fi

	echo "*/5 * * * * root /opt/bamboo-elastic-agent/bin/checkElasticAgent.sh" &gt; /etc/cron.d/elasticagentcheck
# This file doesn't exist on F17 so we use the system control
#	/etc/init.d/crond restart
	/bin/systemctl restart crond.service
else
	echo "This instance will be shut down immediately."
	/sbin/telinit -t 0 0
fi
[bamboo@localhost ~]$ cat /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent 
#!/bin/bash
trap "exit" ERR
BAMBOO_HOME=`dirname $0`/..
unset BAMBOO_CLASSPATH
for JAR in `find $BAMBOO_HOME/lib`
do
  if [[ -n $BAMBOO_CLASSPATH ]]
  then
    BAMBOO_CLASSPATH=$BAMBOO_CLASSPATH:$JAR
  else
    BAMBOO_CLASSPATH=$JAR
  fi
done
# matt.clarkson@gmail.com
# The /etc/rc.d/rc.local script that comes with
# the install doesn't seem to work on F17 so we have moved
# the ampersand here
java -server -Xms32m -Xmx512m -XX:MaxPermSize=256m -cp $BAMBOO_CLASSPATH com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap 2&gt;&amp;1 | tee -a ~/bamboo-elastic-agent.out &amp;

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,069 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot