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

Commit 4c07c23

Browse files
authored
Merge Dev => Master (#348)
* [Orchestrator] Add maximum retry count for missing packages (#342) * Change parsing algorithm from download URL to package id+version (#343) * Change parsing algorithm from download URL to package id+version * PR comments * bug fix * check failing cases * Fix id+version parsing issue for Microsoft.VisualStudio.Shell.15.0 (#347)
1 parent 6fabe69 commit 4c07c23

27 files changed

Lines changed: 418 additions & 131 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
</ItemGroup>
103103
<ItemGroup>
104104
<PackageReference Include="NuGet.Services.Validation.Issues">
105-
<Version>2.14.0</Version>
105+
<Version>2.15.0</Version>
106106
</PackageReference>
107107
</ItemGroup>
108108
<ItemGroup>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ namespace NuGet.Services.Validation.Orchestrator
88
{
99
class Program
1010
{
11-
private const string LoggingCategory = "Validation.Orchestrator";
12-
1311
static int Main(string[] args)
1412
{
1513
if (!args.Contains(JobArgumentNames.Once))
1614
{
1715
args = args.Concat(new[] { "-" + JobArgumentNames.Once }).ToArray();
1816
}
1917
var job = new Job();
20-
JobRunner.Run(job, args).Wait();
18+
JobRunner.Run(job, args).GetAwaiter().GetResult();
2119

2220
// if configuration validation failed, return non-zero status so we can detect failures in automation
2321
return job.ConfigurationValidated ? 0 : 1;

src/NuGet.Services.Validation.Orchestrator/Telemetry/ITelemetryService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public interface ITelemetryService
7979
/// <param name="clientCode">The client code.</param>
8080
void TrackClientValidationIssue(string validatorType, string clientCode);
8181

82+
/// <summary>
83+
/// A counter metric emitted when the orchestrator is requested to validate a package,
84+
/// but, the package does not exist in the Gallery database even after <see cref="ValidationConfiguration.MissingPackageRetryCount"/>
85+
/// retries.
86+
/// </summary>
87+
void TrackMissingPackageForValidationMessage(string packageId, string normalizedVersion, string validationTrackingId);
88+
8289
/// <summary>
8390
/// A metric for the case when orchestrator sees a package marked as available, but the blob is missing
8491
/// in the public container.

src/NuGet.Services.Validation.Orchestrator/Telemetry/TelemetryService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class TelemetryService : ITelemetryService
2121
private const string ValidatorDurationSeconds = Prefix + "ValidatorDurationSeconds";
2222
private const string ValidatorStarted = Prefix + "ValidatorStarted";
2323
private const string ClientValidationIssue = Prefix + "ClientValidationIssue";
24+
private const string MissingPackageForValidationMessage = Prefix + "MissingPackageForValidationMessage";
2425
private const string MissingNupkgForAvailablePackage = Prefix + "MissingNupkgForAvailablePackage";
2526

2627
private const string FromStatus = "FromStatus";
@@ -140,6 +141,17 @@ public void TrackClientValidationIssue(string validatorType, string clientCode)
140141
});
141142
}
142143

144+
public void TrackMissingPackageForValidationMessage(string packageId, string normalizedVersion, string validationTrackingId)
145+
=> _telemetryClient.TrackMetric(
146+
MissingPackageForValidationMessage,
147+
1,
148+
new Dictionary<string, string>
149+
{
150+
{ PackageId, packageId },
151+
{ NormalizedVersion, normalizedVersion },
152+
{ ValidationTrackingId, validationTrackingId },
153+
});
154+
143155
public void TrackMissingNupkgForAvailablePackage(string packageId, string normalizedVersion, string validationTrackingId)
144156
=> _telemetryClient.TrackMetric(
145157
MissingNupkgForAvailablePackage,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public class ValidationConfiguration
2121
/// </summary>
2222
public string ValidationStorageConnectionString { get; set; }
2323

24+
/// <summary>
25+
/// How many times the Orchestrator should retry to validate a package
26+
/// that is missing from the Gallery database.
27+
/// </summary>
28+
public int MissingPackageRetryCount { get; set; }
29+
2430
/// <summary>
2531
/// Time to wait between checking the state of a certain validation.
2632
/// </summary>

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,57 @@
44
using System;
55
using System.Threading.Tasks;
66
using Microsoft.Extensions.Logging;
7+
using Microsoft.Extensions.Options;
78
using NuGet.Services.ServiceBus;
9+
using NuGet.Services.Validation.Orchestrator.Telemetry;
810
using NuGetGallery;
911

1012
namespace NuGet.Services.Validation.Orchestrator
1113
{
1214
public class ValidationMessageHandler : IMessageHandler<PackageValidationMessageData>
1315
{
16+
private readonly ValidationConfiguration _configs;
1417
private readonly ICorePackageService _galleryPackageService;
1518
private readonly IValidationSetProvider _validationSetProvider;
1619
private readonly IValidationSetProcessor _validationSetProcessor;
1720
private readonly IValidationOutcomeProcessor _validationOutcomeProcessor;
21+
private readonly ITelemetryService _telemetryService;
1822
private readonly ILogger<ValidationMessageHandler> _logger;
1923

2024
public ValidationMessageHandler(
25+
IOptionsSnapshot<ValidationConfiguration> validationConfigsAccessor,
2126
ICorePackageService galleryPackageService,
2227
IValidationSetProvider validationSetProvider,
2328
IValidationSetProcessor validationSetProcessor,
2429
IValidationOutcomeProcessor validationOutcomeProcessor,
30+
ITelemetryService telemetryService,
2531
ILogger<ValidationMessageHandler> logger)
2632
{
33+
if (validationConfigsAccessor == null)
34+
{
35+
throw new ArgumentNullException(nameof(validationConfigsAccessor));
36+
}
37+
38+
if (validationConfigsAccessor.Value == null)
39+
{
40+
throw new ArgumentException(
41+
$"The {nameof(IOptionsSnapshot<ValidationConfiguration>)}.{nameof(IOptionsSnapshot<ValidationConfiguration>.Value)} property cannot be null",
42+
nameof(validationConfigsAccessor));
43+
}
44+
45+
if (validationConfigsAccessor.Value.MissingPackageRetryCount < 1)
46+
{
47+
throw new ArgumentOutOfRangeException(
48+
nameof(validationConfigsAccessor),
49+
$"{nameof(ValidationConfiguration)}.{nameof(ValidationConfiguration.MissingPackageRetryCount)} must be at least 1");
50+
}
51+
52+
_configs = validationConfigsAccessor.Value;
2753
_galleryPackageService = galleryPackageService ?? throw new ArgumentNullException(nameof(galleryPackageService));
2854
_validationSetProvider = validationSetProvider ?? throw new ArgumentNullException(nameof(validationSetProvider));
2955
_validationSetProcessor = validationSetProcessor ?? throw new ArgumentNullException(nameof(validationSetProcessor));
3056
_validationOutcomeProcessor = validationOutcomeProcessor ?? throw new ArgumentNullException(nameof(validationOutcomeProcessor));
57+
_telemetryService = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));
3158
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
3259
}
3360

@@ -48,10 +75,28 @@ public async Task<bool> HandleAsync(PackageValidationMessageData message)
4875
if (package == null)
4976
{
5077
// no package in DB yet. Might have received message a bit early, need to retry later
51-
_logger.LogInformation("Did not find information in DB for package {PackageId} {PackageVersion}",
52-
message.PackageId,
53-
message.PackageVersion);
54-
return false;
78+
if (message.DeliveryCount - 1 >= _configs.MissingPackageRetryCount)
79+
{
80+
_logger.LogWarning("Could not find package {PackageId} {PackageVersion} in DB after {DeliveryCount} tries, dropping message",
81+
message.PackageId,
82+
message.PackageVersion,
83+
message.DeliveryCount);
84+
85+
_telemetryService.TrackMissingPackageForValidationMessage(
86+
message.PackageId,
87+
message.PackageVersion,
88+
message.ValidationTrackingId.ToString());
89+
90+
return true;
91+
}
92+
else
93+
{
94+
_logger.LogInformation("Could not find package {PackageId} {PackageVersion} in DB, retrying",
95+
message.PackageId,
96+
message.PackageVersion);
97+
98+
return false;
99+
}
55100
}
56101

57102
var validationSet = await _validationSetProvider.TryGetOrCreateValidationSetAsync(message.ValidationTrackingId, package);

src/NuGet.Services.Validation.Orchestrator/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
}
1111
],
1212
"ValidationStorageConnectionString": "",
13+
"MissingPackageRetryCount": 15,
1314
"ValidationMessageRecheckPeriod": "00:01:00",
14-
"NewValidationRequestDeduplicationWindow": "00:10:00"
15+
"NewValidationRequestDeduplicationWindow": "00:20:00"
1516
},
1617
"Vcs": {
1718
"ContainerName": "validation",

src/PackageHash/PackageHash.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<Version>1.1.2</Version>
8080
</PackageReference>
8181
<PackageReference Include="NuGet.Services.Cursor">
82-
<Version>2.14.0</Version>
82+
<Version>2.15.0</Version>
8383
</PackageReference>
8484
</ItemGroup>
8585
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/Stats.AzureCdnLogs.Common/LogEvents.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class LogEvents
2222
public static EventId FailedToGetFtpResponse = new EventId(512, "Failed to get FTP response");
2323
public static EventId FailedToCheckAlreadyProcessedLogFilePackageStatistics = new EventId(513, "Failed to check already processed package statistics for log file");
2424
public static EventId FailedToCheckAlreadyProcessedLogFileToolStatistics = new EventId(514, "Failed to check already processed tool statistics for log file");
25+
public static EventId MultiplePackageIDVersionParseOptions = new EventId(515, "Multiple package id/version parse options");
26+
public static EventId TranslatedPackageIdVersion = new EventId(516, "Translated package id and version");
2527
public static EventId JobRunFailed = new EventId(550, "Job run failed");
2628
public static EventId JobInitFailed = new EventId(551, "Job initialization failed");
2729
}

src/Stats.AzureCdnLogs.Common/PackageDefinition.cs

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

0 commit comments

Comments
 (0)