-
Notifications
You must be signed in to change notification settings - Fork 908
Description
What happened?
When installing multiple agents on same server, for multiple Projects with same Environment name, the first one installs normally but any further registration attempts kills existing service.
Register agent for ProjectA, environment named Dev:
.\config.cmd` --environment --projectname 'ProjectA' --environmentname "Dev" --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'https://dev.azure.com/OrgName/' --auth PAT
The Windows Service is created using provided parameters for service name and installs/starts normally:
vstsagent.OrgName.Dev.ComputerName
(note that the Registration script does not take into account the Project name)
Register agent for ProjectB on same host, with environment also named Dev:
.\config.cmd` --environment --projectname 'ProjectB' --environmentname "Dev" --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'https://dev.azure.com/OrgName/' --auth PAT
The Registration script detects an existing Windows Service with the same name and tries to overwrite it.
It is not able to create/start Windows Service for ProjectB, and the existing vstsagent.OrgName.Dev.ComputerName service for ProjectA is marked for deletion (which is really bad).
As a workaround, we can customize the agent name:
.\config.cmd` --environment --projectname 'ProjectB' --environmentname "Dev" --agent $env:COMPUTERNAME-ProjectB --runasservice --work '_work' --url 'https://dev.azure.com/OrgName/' --auth PAT
and it then installs properly but the default Registration script (Copy command to clipboard button from Add resource in the Environment) still has this nasty issue and will break existing agents. Honestly I'm quite amazed this issue doesn't seem to have ever been reported yet.
On a side note, the documentation "strongly suggest to only install one agent per machine" (which we'd be more than happy to comply with) but it doesn't seem possible to share an Environment resource between multiple Projects.
Versions
Azure DevOps v4.251.0 / Windows Server 2019
Azure DevOps v3.251.0 / Windows Server 2019
(most likely all versions affected)
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
Windows Server 2019 (most likely all Windows versions affected)
Version controll system
No response
Relevant log output
Log files were deleted before I decided to create this github issue, but this agent installation issue can be reproduced very easily.