Amitabha
Amitabha

Reputation: 1713

TFS: A service host may only be active on one machine at a time. (type BuildServiceHostOwnershipException)

Today we find our tfs bc (build controller) and ba (build agent) does work.
When bc and ba restart, following error event will be logged in Windows Events.

Exception Message: The build service host [build agent name] is currently owned by [build agent name]. A service host may only be active on one machine at a time. (type BuildServiceHostOwnershipException) Exception Stack Trace: at Microsoft.TeamFoundation.Build.Hosting.BuildMachine.StartOperation.End(IAsyncResult result, HttpRouter& router, TfsMessageQueue& messageQueue, List`1& processHosts, MachineLifecycleActivity& traceActivity) at Microsoft.TeamFoundation.Build.Hosting.BuildMachine.EndStart(IAsyncResult result) at Microsoft.TeamFoundation.Build.Machine.WindowsService.EndStartMachine(IAsyncResult result)

Inner Exception Details:

Exception Message: The build service host [build agent name] is currently owned by [build agent name]. A service host may only be active on one machine at a time. (type SoapException)SoapException Details: Exception Stack Trace:

Queued build job will be hang up on step: Run On Agent and at last will fail with following error:

Exception Message: TF400324: Team Foundation services are not available from the server.Technical information (for administrator): Unable to connect to the remote server (type TeamFoundationServiceUnavailableException)Exception Data Dictionary:AgentExecution = FalseException Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)Inner Exception Details:Exception Message: Unable to connect to the remote server (type WebException)Exception Stack Trace: at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.CompleteGetRequestStream(IAsyncResult result) at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.EndGetRequestStream(IAsyncResult result)Inner Exception Details:Exception Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [tfs server ip] (type SocketException)Exception Stack Trace: at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

We have tried to re-register build controller and build agent. But doesn't work.

Upvotes: 3

Views: 4598

Answers (2)

TFS Helper
TFS Helper

Reputation: 11

We ran into this exact issue and it turned out that we had a build server that was cloned which created 2 instances of the same build server. The fix was to unregister the cloned server and reconfigure the original server.

Upvotes: 1

Amitabha
Amitabha

Reputation: 1713

We have tried following solution and it works:
Build controler:
1.Unregister from tfs
2.Unregister from DNS
3.Restart
4.Re-register to DNS
5.Re-register to tfs

Build agent:
1.Unregister from tfs
2.Unregister from DNS
3.Restart
4.Re-register to DNS
5.Re-register to tfs

Then issue is fixed.
==========Add 8/14/2014=======
Recently we faced this issue periodically on build server.
Now we found that all what we should do is to wait. Just about 1 hour later, all are working.
Not sure about root cause.

Upvotes: 4

Related Questions