Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit d746a83

Browse files
authored
Update Service Bus dependencies (#307)
The core logic of Service Bus shutdown was moved to the Service Bus dependencies. This pull request removes the shutdown logic that Service Bus dependency now handles. Part of https://github.com/NuGet/Engineering/issues/1115 Depends on NuGet/ServerCommon#120
1 parent 232a7b0 commit d746a83

21 files changed

Lines changed: 49 additions & 283 deletions

src/NuGet.Services.Validation.Orchestrator/IShutdownNotificationProvider.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/NuGet.Services.Validation.Orchestrator/IShutdownNotificationTokenProvider.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/NuGet.Services.Validation.Orchestrator/Job.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ private void ConfigureJobServices(IServiceCollection services, IConfigurationRoo
149149
services.AddTransient<ConfigurationValidator>();
150150
services.AddTransient<OrchestrationRunner>();
151151

152-
services.AddSingleton<IShutdownNotificationProvider, ShutdownNotificationProvider>();
153-
services.AddSingleton<IShutdownNotificationTokenProvider>(serviceProvider =>
154-
new ShutdownNotificationTokenProvider(serviceProvider.GetRequiredService<IShutdownNotificationProvider>().Token));
155-
156152
services.AddScoped<NuGetGallery.IEntitiesContext>(serviceProvider =>
157153
new NuGetGallery.EntitiesContext(
158154
serviceProvider.GetRequiredService<IOptionsSnapshot<GalleryDbConfiguration>>().Value.ConnectionString,

src/NuGet.Services.Validation.Orchestrator/NuGet.Services.Validation.Orchestrator.csproj

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
<Compile Include="EmailConfiguration.cs" />
5151
<Compile Include="Error.cs" />
5252
<Compile Include="IMessageService.cs" />
53-
<Compile Include="IShutdownNotificationProvider.cs" />
54-
<Compile Include="IShutdownNotificationTokenProvider.cs" />
5553
<Compile Include="IValidationOutcomeProcessor.cs" />
5654
<Compile Include="IValidationSetProcessor.cs" />
5755
<Compile Include="IValidationSetProvider.cs" />
@@ -73,8 +71,6 @@
7371
<Compile Include="Program.cs" />
7472
<Compile Include="Properties\AssemblyInfo.cs" />
7573
<Compile Include="Properties\AssemblyInfo.*.cs" />
76-
<Compile Include="ShutdownNotificationProvider.cs" />
77-
<Compile Include="ShutdownNotificationTokenProvider.cs" />
7874
<Compile Include="SmtpConfiguration.cs" />
7975
<Compile Include="ValidationConfiguration.cs" />
8076
<Compile Include="ValidationConfigurationItem.cs" />
@@ -135,25 +131,25 @@
135131
<Version>1.1.2</Version>
136132
</PackageReference>
137133
<PackageReference Include="NuGet.Services.Configuration">
138-
<Version>2.8.0</Version>
134+
<Version>2.9.0</Version>
139135
</PackageReference>
140136
<PackageReference Include="NuGet.Services.Contracts">
141-
<Version>2.8.0</Version>
137+
<Version>2.9.0</Version>
142138
</PackageReference>
143139
<PackageReference Include="NuGet.Services.KeyVault">
144-
<Version>2.8.0</Version>
140+
<Version>2.9.0</Version>
145141
</PackageReference>
146142
<PackageReference Include="NuGet.Services.Logging">
147-
<Version>2.8.0</Version>
143+
<Version>2.9.0</Version>
148144
</PackageReference>
149145
<PackageReference Include="NuGet.Services.ServiceBus">
150-
<Version>2.8.0</Version>
146+
<Version>2.9.0</Version>
151147
</PackageReference>
152148
<PackageReference Include="NuGet.Services.Validation">
153-
<Version>2.8.0</Version>
149+
<Version>2.9.0</Version>
154150
</PackageReference>
155151
<PackageReference Include="NuGet.Services.Validation.Issues">
156-
<Version>2.8.0</Version>
152+
<Version>2.9.0</Version>
157153
</PackageReference>
158154
<PackageReference Include="NuGet.Versioning">
159155
<Version>4.3.0</Version>

src/NuGet.Services.Validation.Orchestrator/OrchestrationRunner.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ public class OrchestrationRunner
2121

2222
private readonly ISubscriptionProcessor<PackageValidationMessageData> _subscriptionProcessor;
2323
private readonly OrchestrationRunnerConfiguration _configuration;
24-
private readonly IShutdownNotificationProvider _shutdownNotificationProvider;
2524
private readonly ILogger<OrchestrationRunner> _logger;
2625

2726
public OrchestrationRunner(
2827
ISubscriptionProcessor<PackageValidationMessageData> subscriptionProcessor,
2928
IOptionsSnapshot<OrchestrationRunnerConfiguration> configurationAccessor,
30-
IShutdownNotificationProvider shutdownNotificationProvider,
3129
ILogger<OrchestrationRunner> logger)
3230
{
3331
_subscriptionProcessor = subscriptionProcessor ?? throw new ArgumentNullException(nameof(subscriptionProcessor));
3432
configurationAccessor = configurationAccessor ?? throw new ArgumentNullException(nameof(configurationAccessor));
3533
_configuration = configurationAccessor.Value ?? throw new ArgumentException("Value property cannot be null", nameof(configurationAccessor));
36-
_shutdownNotificationProvider = shutdownNotificationProvider ?? throw new ArgumentNullException(nameof(shutdownNotificationProvider));
3734
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
3835
}
3936

@@ -45,25 +42,14 @@ public async Task RunOrchestrationAsync()
4542
await Task.Delay(_configuration.ProcessRecycleInterval);
4643

4744
_logger.LogInformation("Recycling the process...");
48-
_shutdownNotificationProvider.NotifyShutdownInitiated();
49-
var shutdownTask = _subscriptionProcessor.StartShutdownAsync();
50-
// make sure we don't block on waiting shutdownTask to finish
51-
if (await Task.WhenAny(shutdownTask, Task.Delay(_configuration.ShutdownWaitInterval)) != shutdownTask )
45+
46+
if (await _subscriptionProcessor.ShutdownAsync(_configuration.ShutdownWaitInterval))
5247
{
53-
_logger.LogWarning("Failed to wait for shutdown initiation task to finish. Waited for {ShutdownWaitInterval}. Will proceed with task termination",
54-
_configuration.ShutdownWaitInterval);
48+
_logger.LogInformation("Gracefully shutdown the Service Bus subscription processor");
5549
}
56-
57-
DateTimeOffset waitStart = DateTimeOffset.Now;
58-
59-
while (DateTimeOffset.Now - waitStart < _configuration.ShutdownWaitInterval)
50+
else
6051
{
61-
if (_subscriptionProcessor.NumberOfMessagesInProgress <= 0)
62-
{
63-
break;
64-
}
65-
66-
await Task.Delay(ShutdownLoopSleepTime);
52+
_logger.LogWarning("Service Bus subscription processor did not shutdown gracefully");
6753
}
6854

6955
int numStillRunning = _subscriptionProcessor.NumberOfMessagesInProgress;

src/NuGet.Services.Validation.Orchestrator/ShutdownNotificationProvider.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/NuGet.Services.Validation.Orchestrator/ShutdownNotificationTokenProvider.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/NuGet.Services.Validation.Orchestrator/ValidationMessageHandler.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,24 @@ public class ValidationMessageHandler : IMessageHandler<PackageValidationMessage
1515
private readonly IValidationSetProvider _validationSetProvider;
1616
private readonly IValidationSetProcessor _validationSetProcessor;
1717
private readonly IValidationOutcomeProcessor _validationOutcomeProcessor;
18-
private readonly IShutdownNotificationTokenProvider _shutdownNotificationTokenProvider;
1918
private readonly ILogger<ValidationMessageHandler> _logger;
2019

2120
public ValidationMessageHandler(
2221
ICorePackageService galleryPackageService,
2322
IValidationSetProvider validationSetProvider,
2423
IValidationSetProcessor validationSetProcessor,
2524
IValidationOutcomeProcessor validationOutcomeProcessor,
26-
IShutdownNotificationTokenProvider shutdownNotificationTokenProvider,
2725
ILogger<ValidationMessageHandler> logger)
2826
{
2927
_galleryPackageService = galleryPackageService ?? throw new ArgumentNullException(nameof(galleryPackageService));
3028
_validationSetProvider = validationSetProvider ?? throw new ArgumentNullException(nameof(validationSetProvider));
3129
_validationSetProcessor = validationSetProcessor ?? throw new ArgumentNullException(nameof(validationSetProcessor));
3230
_validationOutcomeProcessor = validationOutcomeProcessor ?? throw new ArgumentNullException(nameof(validationOutcomeProcessor));
33-
_shutdownNotificationTokenProvider = shutdownNotificationTokenProvider ?? throw new ArgumentNullException(nameof(shutdownNotificationTokenProvider));
34-
if (shutdownNotificationTokenProvider.Token == null)
35-
{
36-
throw new ArgumentException($"{nameof(shutdownNotificationTokenProvider.Token)} property cannot be null", nameof(shutdownNotificationTokenProvider));
37-
}
3831
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
3932
}
4033

4134
public async Task<bool> HandleAsync(PackageValidationMessageData message)
4235
{
43-
if (_shutdownNotificationTokenProvider.Token.IsCancellationRequested)
44-
{
45-
_logger.LogInformation("Service shutdown was requested, will not process new message");
46-
return false;
47-
}
48-
4936
var package = _galleryPackageService.FindPackageByIdAndVersionStrict(message.PackageId, message.PackageVersion);
5037

5138
if (package == null)

src/Validation.Callback.Vcs/Web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</dependentAssembly>
7171
<dependentAssembly>
7272
<assemblyIdentity name="NuGet.Services.KeyVault" publicKeyToken="31bf3856ad364e35" culture="neutral" />
73-
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0" />
73+
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
7474
</dependentAssembly>
7575
<dependentAssembly>
7676
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />

src/Validation.Common/Validation.Common.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@
105105
<Reference Include="NuGet.ApplicationInsights.Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106106
<HintPath>..\..\packages\NuGet.ApplicationInsights.Owin.4.1.0\lib\net452\NuGet.ApplicationInsights.Owin.dll</HintPath>
107107
</Reference>
108-
<Reference Include="NuGet.Services.KeyVault, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109-
<HintPath>..\..\packages\NuGet.Services.KeyVault.2.8.0\lib\net45\NuGet.Services.KeyVault.dll</HintPath>
108+
<Reference Include="NuGet.Services.KeyVault, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109+
<HintPath>..\..\packages\NuGet.Services.KeyVault.2.9.0\lib\net45\NuGet.Services.KeyVault.dll</HintPath>
110110
</Reference>
111-
<Reference Include="NuGet.Services.Logging, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
112-
<HintPath>..\..\packages\NuGet.Services.Logging.2.8.0\lib\net452\NuGet.Services.Logging.dll</HintPath>
111+
<Reference Include="NuGet.Services.Logging, Version=2.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
112+
<HintPath>..\..\packages\NuGet.Services.Logging.2.9.0\lib\net452\NuGet.Services.Logging.dll</HintPath>
113113
</Reference>
114114
<Reference Include="NuGet.Services.VirusScanning.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115115
<HintPath>..\..\packages\NuGet.Services.VirusScanning.Vcs.3.2.0\lib\net452\NuGet.Services.VirusScanning.Core.dll</HintPath>

0 commit comments

Comments
 (0)