Remote Agent fails to run job on host machine, until it is configured manually every time
Asked by neha.chauhan:

Hi All,

I am consistently facing an issue while running jobs from bamboo where a remote agent has already been configured on the host machine.

When I run my jobs from bamboo, in some instances, it fails to execute my plan/job and in other instances, starts executing the job on some other machine other than the host machine.

Job runs but I am not able to see any execution happening on the host machine.

I have to follow below steps to run my jobs on the host machine.

1. Delete the remote agent from bamboo

2. Stop the bamboo remote agent services from background processes

3. Execute batch file 'BambooAgent' from agent's bin folder to configure the agent

4. Start the backend services again

5. Add required capabilities to the agent (on the basis of the selected plan)

6. Run the plan

Since, I have to follow these steps manually every time to run my jobs, I am assuming the agent might be going offline, not sure though because the status of the agent shows 'idle'.

My Question: Is this issue happening because the agent goes offline? If Yes, How can I always keep it active?

also, Does restarting the machine results into these issues?

\*I assume configuring an agent using above steps, is a one-time activity and if it could stay active/online all the time, these set of steps may not be required.

Request the support team to Please help on the same.


Answers:
author: Daniel Santos
body: Hi [@neha.chauhan](/t5/user/viewprofilepage/user-id/2854546)  

A combination of things could cause the scenario you are experiencing there:

1. **Capabilities / Agent dedication**   
   A build can be taken by any remote agent with capabilities enough to build it. The agent can be in any machine and therefore the build can happen anywhere.
2. **Is the Agent really working?** The agent might be failing and the windows service still shows it as online (I'm assuming your environment is Windows - please correct me if I'm wrong). In this is the case, you need to check the *\<Bamboo_Agent_Home\>/logs/atlassian-bamboo.log*to understand what is happening there
3. **Is the agent considered online by Bamboo?** The bamboo server will need about 10min to really identify if an agent is offline or not, therefore, showing it as idle. There is an improvement request to reduce this time here: [\[BAM-20275\] Reduce the time taken to identify an agent is offline - Create and track feature requests for Atlassian products.](https://jira.atlassian.com/browse/BAM-20275)

I'm not really sure if we will be able to dig deeper on this issue from a community question. We might need to create a support ticket to be able to check your logs.

* Have you checked the agent logs?
* Have you tried dedicating the agent you are mentioning the plan you are running?  
  [Dedicating an agent - Atlassian Documentation](https://confluence.atlassian.com/bamboo/dedicating-an-agent-629015108.html)

comments: author: neha.chauhan
body: Hi Daniel,

Thanks for responding on my questions.I was off work so couldn't get back earlier.

PFB my updates on your queries:

Capabilities / Agent dedication  
A build can be taken by any remote agent with capabilities enough to build it. The agent can be in any machine and therefore the build can happen anywhere.  
***The agent is installed on the same machine where I am running the jobs from. However, I can see other bamboo agents folders under C:Drive on windows 10 but One specific agent (from BambooAgent.bat under the agent folder) is installed on the host machine, everytime it goes offline.***

<br />

Is the Agent really working?  
The agent might be failing and the windows service still shows it as online (I'm assuming your environment is Windows - please correct me if I'm wrong). In this is the case, you need to check the \<Bamboo_Agent_Home\>/logs/atlassian-bamboo.log to understand what is happening there  
Is the agent considered online by Bamboo?  
***If I follow the steps I have mentioned above, then my job runs as expected till a couple of iterations and then again the headless execution starts where I can see my tests running in the logs but nothing happens on the machine.***   
***During this headless execution, logs captured shows following:***

***Remote service is inactive***   
***Browser process stopped: exit code: 0***

Have you tried dedicating the agent you are mentioning the plan you are running?  
Dedicating an agent - Atlassian Documentation  
***I am not able to dedicate agent to selected build plan as no action is being performed on clicking 'Add' button, the button doesn't seem to work. Is this is an issue?***

***One of the things that I did while trying to resolve this issue is, stopped the 'Bamboo Remote Agent' services from backend(services.msc) and this worked in a way that the agent did'nt go offline till the time I was working on the machine but then again went offline during onshore working hours.***   
***This could fail the jobs because this agent has to be kept active as DEV team will release a build during Onshore working hours, that will trigger my bamboo job.***

Also, I came across one configuration in bamboo where we can set the desired the timings in following parameters but that requires bamboo server restart.

initialReconnectDelay=30000  
maxReconnectAttempts=1000  
Could you please confirm if this will work or if there's anything else that I can do to make it work?

Regards,

Neha


author: Daniel Santos
body: Hi [@neha.chauhan](/t5/user/viewprofilepage/user-id/2854546)

I was reviewing this thread and I'm still confused on what is the behavior you see there. It might be the case that a deeper investigation with the support team needs to take place.  

You say the agent is idle and that other agents are taking the builds. That seems to me just a matter of setting the right requirements or dedicating the correct agent so other agents will not take the build... I guess the scenario is not clear for me yet.  

I'll open a support ticket for this case in your name so our team can investigate this issue further.  

You should receive a notification about it soon.