From b394f148bb70b36f96ffcb4515bce9ab7844c55b Mon Sep 17 00:00:00 2001 From: Tomek Masternak Date: Tue, 6 Apr 2021 14:29:03 +0200 Subject: [PATCH 1/4] adding aclurl for all hostnames in the maintenance mode --- .../Instances/ServiceControlBaseService.cs | 19 ++++++++++++++++--- .../Instances/ServiceControlNewInstance.cs | 2 +- .../NewServiceControlAuditInstance.cs | 1 - 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs index e9c421642a..0feaac47e1 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs @@ -66,7 +66,7 @@ public string AclUrl } } - public string AclMaintenanceUrl + public string LegacyAclMaintenanceUrl { get { @@ -75,6 +75,15 @@ public string AclMaintenanceUrl } } + public string AclMaintenanceUrl + { + get + { + var baseUrl = $"http://+:{DatabaseMaintenancePort}/"; + return baseUrl; + } + } + public string LogPath { get; set; } public string DBPath { get; set; } public string HostName { get; set; } @@ -208,8 +217,12 @@ protected string DefaultLogPath() public void RemoveUrlAcl() { - foreach (var urlReservation in UrlReservation.GetAll().Where(p => p.Url.StartsWith(AclUrl, StringComparison.OrdinalIgnoreCase) || - p.Url.StartsWith(AclMaintenanceUrl, StringComparison.OrdinalIgnoreCase))) + bool IsServiceControlAclUrl(UrlReservation r) => + r.Url.StartsWith(AclUrl, StringComparison.OrdinalIgnoreCase) || + r.Url.StartsWith(AclMaintenanceUrl, StringComparison.OrdinalIgnoreCase) || + r.Url.StartsWith(LegacyAclMaintenanceUrl, StringComparison.OrdinalIgnoreCase); + + foreach (var urlReservation in UrlReservation.GetAll().Where(IsServiceControlAclUrl)) { try { diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs index 6d02fd9d3b..b39d2aa6f1 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlNewInstance.cs @@ -225,7 +225,7 @@ public string AclMaintenanceUrl { get { - var baseUrl = $"http://{HostName}:{DatabaseMaintenancePort}/"; + var baseUrl = $"http://+:{DatabaseMaintenancePort}/"; return baseUrl; } } diff --git a/src/ServiceControlInstaller.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs b/src/ServiceControlInstaller.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs index b3f1b776a4..ad0615a93c 100644 --- a/src/ServiceControlInstaller.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs +++ b/src/ServiceControlInstaller.PowerShell/Cmdlets/AuditInstances/NewServiceControlAuditInstance.cs @@ -1,7 +1,6 @@ namespace ServiceControlInstaller.PowerShell { using System; - using System.IO; using System.Linq; using System.Management.Automation; using Engine.Instances; From 799eeec02d0d71ef78fb7628539acf592ec10106 Mon Sep 17 00:00:00 2001 From: Tomek Masternak Date: Tue, 6 Apr 2021 14:44:58 +0200 Subject: [PATCH 2/4] fixing newlines --- .../Instances/ServiceControlBaseService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs index 0feaac47e1..7ca3597486 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs @@ -217,9 +217,9 @@ protected string DefaultLogPath() public void RemoveUrlAcl() { - bool IsServiceControlAclUrl(UrlReservation r) => - r.Url.StartsWith(AclUrl, StringComparison.OrdinalIgnoreCase) || - r.Url.StartsWith(AclMaintenanceUrl, StringComparison.OrdinalIgnoreCase) || + bool IsServiceControlAclUrl(UrlReservation r) => + r.Url.StartsWith(AclUrl, StringComparison.OrdinalIgnoreCase) || + r.Url.StartsWith(AclMaintenanceUrl, StringComparison.OrdinalIgnoreCase) || r.Url.StartsWith(LegacyAclMaintenanceUrl, StringComparison.OrdinalIgnoreCase); foreach (var urlReservation in UrlReservation.GetAll().Where(IsServiceControlAclUrl)) From 1d9726e5a90ab8c9891c0c2173aef39efca868dc Mon Sep 17 00:00:00 2001 From: Tomek Masternak Date: Tue, 6 Apr 2021 15:11:23 +0200 Subject: [PATCH 3/4] comment on legacy property --- .../Instances/ServiceControlBaseService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs index 7ca3597486..834b083e3f 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs @@ -66,6 +66,9 @@ public string AclUrl } } + //This is an old aclurl registration for embedded RavenDB instance that includes the hostname. + //We need that to make sure we can clean-up old registration when removing instances created + //using pre 4.17 versions of ServiceControl. public string LegacyAclMaintenanceUrl { get From ad8eea66b7a31a3fed67a37747951a6de6585e08 Mon Sep 17 00:00:00 2001 From: Tomek Masternak Date: Wed, 7 Apr 2021 09:42:53 +0200 Subject: [PATCH 4/4] inlining the legacyaclurl property --- .../Instances/ServiceControlBaseService.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs index 834b083e3f..320cfeec87 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs @@ -66,18 +66,6 @@ public string AclUrl } } - //This is an old aclurl registration for embedded RavenDB instance that includes the hostname. - //We need that to make sure we can clean-up old registration when removing instances created - //using pre 4.17 versions of ServiceControl. - public string LegacyAclMaintenanceUrl - { - get - { - var baseUrl = $"http://{HostName}:{DatabaseMaintenancePort}/"; - return baseUrl; - } - } - public string AclMaintenanceUrl { get @@ -220,10 +208,15 @@ protected string DefaultLogPath() public void RemoveUrlAcl() { + //This is an old aclurl registration for embedded RavenDB instance that includes the hostname. + //We need that to make sure we can clean-up old registration when removing instances created + //using pre 4.17 versions of ServiceControl. + var legacyAclMaintenanceUrl = $"http://{HostName}:{DatabaseMaintenancePort}/"; + bool IsServiceControlAclUrl(UrlReservation r) => r.Url.StartsWith(AclUrl, StringComparison.OrdinalIgnoreCase) || r.Url.StartsWith(AclMaintenanceUrl, StringComparison.OrdinalIgnoreCase) || - r.Url.StartsWith(LegacyAclMaintenanceUrl, StringComparison.OrdinalIgnoreCase); + r.Url.StartsWith(legacyAclMaintenanceUrl, StringComparison.OrdinalIgnoreCase); foreach (var urlReservation in UrlReservation.GetAll().Where(IsServiceControlAclUrl)) {