Waiting for an available agent / Waiting for an agent to be requested
Asked Answered
Q

1

16

(26.07.2016)I am using TFS2015 Update3 in a VM. When I try to queue a build through the web interface or from Team Explorer, I get the following. Then I restart all services related to TFS in services.msc and then after some time it starts working again.

So this happens too often.

enter image description here

I have a custom pool running: enter image description here

Is there a way to debug this behaviour?

Examining the Log files

Link to Worker log file
Link to Agent log file

Exception occurs in this order here:

  1. Checking if artifacts directory exists C:\workspaces\agent\_work\2\a
  2. Deleting artifacts directory
  3. System.ComponentModel.Win32Exception (0x80004005): The directory is not empty
    at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryLongPath(String path, Boolean recursive, Boolean followJunctionPoints)

The weird thing is, queueing new build works most of the time, this happens only sporadically

It could be, that I have opened a file from that folder in notepad with many tabs open. Will observe if this issue persists and report.

Qoph answered 26/7, 2016 at 14:9 Comment(12)
I've seen this happen when the build definition is in an invalid state, i.e. it was saved without validation errors but some aspect of the configuration is wrong. One specific example was trying to use variables in the server path mappings e.g. $\myapp\$(branch) under the Repository tab. This resulted in the build just waiting for agent, which is pretty unhelpful. I've not found a way to debug it.Jeanett
Ok, but in my case the build agent is working, then it hangs like explained above. Then I restart every TFS Service under services I can find. Close the web page. Queue a new build then it mostly works again after some time. What I also expirienced is, that soemtimes it hangs but the build is running in the background, I can see the drop folder getting populated. Not sure about this, perhaps I have queued multiple builds one after the other... It would be nice to know, where to start digging...Qoph
Did you check the log in \agent_diag? Any useful information there? Also, make sure your agent service is under running status.Flo
Added the log file at the end of my question. Now I can see the following exceptions inside the log: DeleteDirectoryLongPath and Win32Exception and TaskCanceledException appear...Qoph
System.ComponentModel.Win32Exception (0x80004005): The directory is not emptyQoph
But it has nothing to do with the build definition I guess, because i can queue it 5 times and it passes all steps. When it hangs I get the above messages in the log file.Qoph
Same thing is happening to me. It just bails randomly with the "directory is not empty" error. Nobody is logged into the build server, so it doesn't appear to be a locking issue caused by a user. Re-enqueueing the build fixes the problem until next time.Incumber
this weired things can happen due to permission issues, you dont get a qualified pointer to what the actual problem is. Try to install the latest TFS patch if u haven't already.Qoph
RE @pero's comment of "I've seen this happen when the build definition is in an invalid state, i.e. it was saved without validation errors but some aspect of the configuration is wrong." In my case a Server Path of the Repository Mappings started with a space!Kernan
Restarting "Visual Studio Team Foundation Background Job Agent" has worked for me. Not sure why...Variorum
I'm from the product team - email me. bryanmac and that's at microsoft. I'll get someone on this. Also note that TFS2017 QU1 (and QU2 impending) had some fixes in this area. Not sure if that's a possibility ...Shrove
I got this after rebooting my TFS box. Next build got stuck at this stage for a worrying amount of time and then sprang in to life.Postexilian
S
1

If this is happening sporadically, it might a long path exists here in artifacts:

C:\workspaces\agent_work\2\a

Or, there was a cancelled build which left the artifact directory half cleaned which exposed a bug in cleaning.

The 2.x agent isn't subject to long paths (net core) but only works with 2017+:

https://github.com/Microsoft/vsts-agent

We can troubleshoot but it would be good to get to 2017+ (2018 QU3 is out) with a 2.x agent.

If that's not an option, message me and we can dig into what I think is a cancel / state bug.

Shrove answered 22/8, 2018 at 1:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.