From cf6e2190cb1c355ca1b413428ed46aaf89294665 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 29 Oct 2023 20:31:33 +0530 Subject: [PATCH] Failover.HealthService: updated Initialize() to set maintenance status immediately for health monitors. --- Apps/FailoverApp/HealthService.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Apps/FailoverApp/HealthService.cs b/Apps/FailoverApp/HealthService.cs index 99536d0d..dcc73c30 100644 --- a/Apps/FailoverApp/HealthService.cs +++ b/Apps/FailoverApp/HealthService.cs @@ -342,7 +342,24 @@ namespace Failover else enabled = true; - _underMaintenance.TryAdd(NetworkAddress.Parse(network), enabled); + NetworkAddress umNetwork = NetworkAddress.Parse(network); + + if (_underMaintenance.TryAdd(umNetwork, enabled)) + { + if (enabled) + { + foreach (KeyValuePair healthMonitor in _healthMonitors) + { + HealthMonitor monitor = healthMonitor.Value; + + if (monitor.Address is null) + continue; + + if (umNetwork.Contains(monitor.Address)) + monitor.SetUnderMaintenance(); + } + } + } } } }