Q:

Pipeline Release's to environment fail tests

In our release pipeline within TFS (on prem) the Run Functional test task are having redundant logs with "Test run  is in 'InProgress' state ". 
After several repetition (some times up to the time-out level) of the same message the test is aborted causing the task to be failed. Reattempting would execute test case to success.  We do not have this issue on our build server only when we test what we have released to an environment.
We want to know the root cause and resolution for this issue.
We do have a Test Agent installed on the  Server so that the test are performed there.  
Here is an example of what we sometimes see that is causing the issue. 
2019-10-02T15:08:02.6850117Z DistributedTests: build id: 6374

2019-10-02T15:08:02.6850117Z DistributedTests: test configuration mapping: 
2019-10-02T15:08:02.9506501Z DistributedTests: Test Run with Id 3439 Queued
2019-10-02T15:08:03.0450717Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:08:13.1288425Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:08:23.1965836Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:08:33.2571132Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:08:43.3372572Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:08:53.4159907Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:03.4760176Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:13.5396749Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:23.5995694Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:33.6578911Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:43.7221898Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:09:53.8077140Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:03.8614622Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:13.9438805Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:24.0015664Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:34.0601261Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:44.1201041Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:10:54.1826966Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:04.2538091Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:14.3385817Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:24.3927960Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:34.4611704Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:44.5277491Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:11:54.5927946Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:04.6715006Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:14.7412140Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:24.8137052Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:34.8707487Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:44.9422325Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:12:55.0129476Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:05.1284906Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:15.1900203Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:25.2565799Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:35.3280345Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:45.3982751Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:13:55.4603385Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:05.5207280Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:15.5857792Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:25.6530083Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:35.7347753Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:45.7941659Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:14:55.8551101Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:05.9238471Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:15.9829484Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:26.0513261Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:36.1212279Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:46.2300557Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:15:56.2810072Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:06.3525471Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:16.4174982Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:26.4911422Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:36.5562109Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:46.6349393Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:16:56.6933076Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:06.7679881Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:16.8282799Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:26.8957535Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:36.9561716Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:47.0226277Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:17:57.0822145Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:07.1718473Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:17.2482416Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:27.3100487Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:37.3705919Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:47.4270207Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:18:57.4878769Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:07.5784610Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:17.6583487Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:27.7184931Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:37.7861986Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:47.8453393Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:19:57.9135570Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:07.9783979Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:18.0400239Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:28.1168838Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:38.1722693Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:48.2345722Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:20:58.2978591Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:08.3585618Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:18.4180230Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:28.4809123Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:38.5409894Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:48.6067102Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:21:58.6745500Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:08.7298142Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:18.8020461Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:28.8787059Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:38.9554949Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:49.0238237Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:22:59.0795040Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:23:09.1508546Z DistributedTests: Test run '3439' is in 'InProgress' state.
2019-10-02T15:23:19.2118167Z DistributedTests: Test run '3439' is in 'Aborted' state.
2019-10-02T15:23:29.2214050Z ##[warning]DistributedTests: Test run is aborted. Logging details of the run logs.
2019-10-02T15:23:29.2370197Z ##[warning]DistributedTests: New test run created.
2019-10-02T15:23:29.2370197Z Test Run queued for Project Collection Build Service (EnterpriseA).
2019-10-02T15:23:29.2370197Z 
2019-10-02T15:23:29.2370197Z ##[warning]DistributedTests: Test discovery started.
2019-10-02T15:23:29.2370197Z ##[warning]DistributedTests: UnExpected error occured during test execution. Try again.
2019-10-02T15:23:29.2370197Z ##[warning]DistributedTests: Error : Some tests could not run because all test agents of this testrun were unreachable for long time. Ensure that all testagents are able to communicate with the server and retry again.
2019-10-02T15:23:29.2370197Z 
2019-10-02T15:23:29.2370197Z ##[warning]DistributedTests: Test run aborted. Test run id: 3439
2019-10-02T15:23:29.2370197Z ##[error]System.Exception: The test run was aborted, failing the task.
2019-10-02T15:23:29.2838927Z ##[error]PowerShell script completed with 1 errors.

A:

This is a known issue for Run Functional test task. A single test run timed out cause that test run aborted, finally fail the task.   

We have fixed this issue and it's available in TFS 2018 Update 1 and
  VSTS. 
We are asking folks to move to the VsTest v2 task that is capable of
  parallel execution both in release and build.

For more detail info you could refer below two similar questions:

Run Functional Tests: The test run was aborted, failing the task
Release: Run Functional Tests Task Issue: The test run was aborted,
failing the task - DistributedTests: Test run timed out

According to your tag, seems you are still working on TFS2017. Unfortunately, there isn't any better workaround expect  reattempt as you pointed out in question.  
Suggest you upgrade to TFS 2018 and use 2.x or higher Visual Studio Test task instead.
Run Functional test task is deprecated in Azure Pipelines and TFS 2018 and later. Use version 2.x or higher of the Visual Studio Test task together with jobs to run unit and functional tests on the universal agent.
Hope this helps.

