mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-02 21:15:05 +00:00
Add one minute back-off level for all providers
(cherry picked from commit d8f314ff0ef64e8d90b21b7865e46be74db5e570) Closes #3989
This commit is contained in:
parent
0629c306e4
commit
98ae377aff
3 changed files with 7 additions and 5 deletions
|
@ -34,6 +34,7 @@ public MockProviderStatusService(IMockProviderStatusRepository providerStatusRep
|
|||
|
||||
public class ProviderStatusServiceFixture : CoreTest<MockProviderStatusService>
|
||||
{
|
||||
private readonly TimeSpan _disabledTillPrecision = TimeSpan.FromMilliseconds(500);
|
||||
private DateTime _epoch;
|
||||
|
||||
[SetUp]
|
||||
|
@ -90,7 +91,7 @@ public void should_start_backoff_on_first_failure()
|
|||
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
||||
status.Should().NotBeNull();
|
||||
status.DisabledTill.Should().HaveValue();
|
||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
|
||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(1), _disabledTillPrecision);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -133,7 +134,7 @@ public void should_preserve_escalation_on_intermittent_success()
|
|||
var status = Subject.GetBlockedProviders().FirstOrDefault();
|
||||
status.Should().NotBeNull();
|
||||
status.DisabledTill.Should().HaveValue();
|
||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(15), 500);
|
||||
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -160,7 +161,7 @@ public void should_not_escalate_further_than_5_minutes_for_15_min_after_startup(
|
|||
status.Should().NotBeNull();
|
||||
|
||||
origStatus.EscalationLevel.Should().Be(3);
|
||||
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
|
||||
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
namespace NzbDrone.Core.ThingiProvider.Status
|
||||
namespace NzbDrone.Core.ThingiProvider.Status
|
||||
{
|
||||
public static class EscalationBackOff
|
||||
{
|
||||
public static readonly int[] Periods =
|
||||
{
|
||||
0,
|
||||
60,
|
||||
5 * 60,
|
||||
15 * 60,
|
||||
30 * 60,
|
||||
|
|
|
@ -116,7 +116,7 @@ protected virtual void RecordFailure(int providerId, TimeSpan minimumBackOff, bo
|
|||
|
||||
if (inStartupGracePeriod && minimumBackOff == TimeSpan.Zero && status.DisabledTill.HasValue)
|
||||
{
|
||||
var maximumDisabledTill = now + TimeSpan.FromSeconds(EscalationBackOff.Periods[1]);
|
||||
var maximumDisabledTill = now + TimeSpan.FromSeconds(EscalationBackOff.Periods[2]);
|
||||
if (maximumDisabledTill < status.DisabledTill)
|
||||
{
|
||||
status.DisabledTill = maximumDisabledTill;
|
||||
|
|
Loading…
Reference in a new issue