Particular / ServiceControl

Backend for ServiceInsight and ServicePulse
https://docs.particular.net/servicecontrol/
Other
53 stars 47 forks source link

System.ArgumentException: UrlAcl is invalid when creating a new instance of Service Control if you have CosmosDb emulator running #1050

Closed alexw1983 closed 6 years ago

alexw1983 commented 6 years ago

TLDR I can't add a new Service Control instance if I have the Azure Cosmos Db Emulator installed.

The Story: This one's a bit weird and took us a while to get to the bottom of, so I think it's worth raising as an FYI.

I was trying to add a new instance and got the following exception:

System.ArgumentException: UrlAcl is invalid
   at ServiceControlInstaller.Engine.UrlAcl.UrlReservation..ctor(String url, SecurityIdentifier[] securityIdentifiers) in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControlInstaller.Engine\UrlAcl\UrlReservation.cs:line 49
   at ServiceControlInstaller.Engine.UrlAcl.UrlReservation.GetAll() in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControlInstaller.Engine\UrlAcl\UrlReservation.cs:line 149
   at ServiceControlInstaller.Engine.Instances.ServiceControlNewInstance.CheckForConflictingUrlAclReservations() in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControlInstaller.Engine\Instances\ServiceControlNewInstance.cs:line 276
   at ServiceControlInstaller.Engine.Instances.ServiceControlNewInstance.Validate(Func`2 promptToProceed) in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControlInstaller.Engine\Instances\ServiceControlNewInstance.cs:line 252
   at ServiceControl.Config.Framework.Modules.ServiceControlInstanceInstaller.Add(ServiceControlNewInstance details, IProgress`1 progress, Func`2 promptToProceed) in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControl.Config\Framework\Modules\InstallerModule.cs:line 41
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ServiceControl.Config.UI.InstanceAdd.ServiceControlAddAttachment.<Add>d__6.MoveNext() in C:\BuildAgent\work\7189a56f9f44affc\src\ServiceControl.Config\UI\InstanceAdd\ServiceControlAddAttachment.cs:line 85

After a bit of digging I found that when creating a new Service Control instance it loads a list of the UrlAcl entries and compares them to a Regex statement.

So I ran the following command to see a list of UrlAcl entries on my machine:

netsh http show urlacl

I have the Azure Cosmos Db Emulator running on my machine which adds many of these UrlAcl entries of the format:

Reserved URL : https://[::1]:10253/ User: BUDLT04\DocDBServerService Listen: Yes Delegate: No SDDL: D:(A;;GX;;;S-1-5-21-1316257521-2492885212-1563718246-1006)

Note the double semi-colon in the Reserved Url.

There about 10 of them but I have just included one for reference. In order to be able to add the new Service Control instance I had to manually remove all of the DocDbService UrlAcl entries and then it worked.

For reference, you can remove the UrlAcl entries using:

netsh http delete urlacl url=https://10.1.3.32:10252/

My suspicion is that the regex doesn't handle this format of URL.

This could be a problem with the Cosmos Db Emulator but I think there might be a chance that other software could add URL s in this format. So it might be useful to either extend the regex to handle this or give a more specific message that indicates that it is not the URL that you are adding causing the problem but the reserved URLs already on the machine causing the problem.

Steps to Replicate

  1. Install the Azure Cosmos DB emulator. ( iused choclately cinst azure-documentdb-emulator -y)
  2. Install the Particular Software installer, Install Service Control and try and add a new Service Control Instance. I am using Azure Service Bus as a transport instance.
WilliamBZA commented 6 years ago

Wow, great investigation work @alexw1983!

\

I have a unit test confirming the behaviour is as you described.

WilliamBZA commented 6 years ago

PR Submitted, waiting for review

WilliamBZA commented 6 years ago

PR merged. The fix for this will go out with 1.44.1