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

Commit 781b094

Browse files
authored
Merge pull request #676 from NuGet/dev
[ReleasePrep][2018.11.20]RI of dev into master
2 parents 76a5cf1 + 8459db8 commit 781b094

17 files changed

Lines changed: 353 additions & 197 deletions

src/NuGet.Services.Revalidate/Services/RevalidationJobStateService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ await _state.MaybeUpdateStateAsync(state =>
104104
return false;
105105
}
106106

107-
var nextRate = Math.Min(_config.MaxPackageEventRate, state.DesiredPackageEventRate + 1);
107+
var nextRate = state.DesiredPackageEventRate + _config.Queue.MaxBatchSize;
108+
nextRate = Math.Min(_config.MaxPackageEventRate, nextRate);
108109

109110
_logger.LogInformation(
110111
"Increasing desired package event rate to {ToRate} from {FromRate}",

src/StatusAggregator/Export/ComponentExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public IComponent Export()
7171
foreach (var activeEntity in activeEntities)
7272
{
7373
using (_logger.Scope("Applying active entity affecting {AffectedComponentPath} of severity {AffectedComponentStatus} at {StartTime} to root component",
74-
activeEntity.AffectedComponentPath, activeEntity.AffectedComponentStatus, activeEntity.StartTime))
74+
activeEntity.AffectedComponentPath, (ComponentStatus)activeEntity.AffectedComponentStatus, activeEntity.StartTime))
7575
{
7676
var currentComponent = rootComponent.GetByPath(activeEntity.AffectedComponentPath);
7777

src/StatusAggregator/Export/IStatusSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace StatusAggregator.Export
1111
public interface IStatusSerializer
1212
{
1313
/// <summary>
14-
/// Serializes <paramref name="rootComponent"/> and <paramref name="recentEvents"/> and saves to storage with a time of <paramref name="cursor"/>.
14+
/// Serializes <paramref name="rootComponent"/> and <paramref name="recentEvents"/> and saves to storage with a last built time of <paramref name="lastBuilt"/> and a last updated time of <paramref name="lastUpdated"/>.
1515
/// </summary>
16-
Task Serialize(DateTime cursor, IComponent rootComponent, IEnumerable<Event> recentEvents);
16+
Task Serialize(DateTime lastBuilt, DateTime lastUpdated, IComponent rootComponent, IEnumerable<Event> recentEvents);
1717
}
1818
}

src/StatusAggregator/Export/StatusExporter.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,43 @@
55
using System.Threading.Tasks;
66
using Microsoft.Extensions.Logging;
77
using NuGet.Jobs.Extensions;
8+
using StatusAggregator.Collector;
9+
using StatusAggregator.Update;
810

911
namespace StatusAggregator.Export
1012
{
1113
public class StatusExporter : IStatusExporter
1214
{
15+
private readonly ICursor _cursor;
1316
private readonly IComponentExporter _componentExporter;
1417
private readonly IEventsExporter _eventExporter;
1518
private readonly IStatusSerializer _serializer;
1619

1720
private readonly ILogger<StatusExporter> _logger;
1821

1922
public StatusExporter(
23+
ICursor cursor,
2024
IComponentExporter componentExporter,
2125
IEventsExporter eventExporter,
2226
IStatusSerializer serializer,
2327
ILogger<StatusExporter> logger)
2428
{
29+
_cursor = cursor ?? throw new ArgumentNullException(nameof(cursor));
2530
_componentExporter = componentExporter ?? throw new ArgumentNullException(nameof(componentExporter));
2631
_eventExporter = eventExporter ?? throw new ArgumentNullException(nameof(eventExporter));
2732
_serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
2833
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2934
}
3035

31-
public Task Export(DateTime cursor)
36+
public async Task Export(DateTime cursor)
3237
{
3338
using (_logger.Scope("Exporting service status."))
3439
{
3540
var rootComponent = _componentExporter.Export();
3641
var recentEvents = _eventExporter.Export(cursor);
37-
return _serializer.Serialize(cursor, rootComponent, recentEvents);
42+
43+
var lastUpdated = await _cursor.Get(StatusUpdater.LastUpdatedCursorName);
44+
await _serializer.Serialize(cursor, lastUpdated, rootComponent, recentEvents);
3845
}
3946
}
4047
}

src/StatusAggregator/Export/StatusSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public StatusSerializer(
3636
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
3737
}
3838

39-
public async Task Serialize(DateTime cursor, IComponent rootComponent, IEnumerable<Event> recentEvents)
39+
public async Task Serialize(DateTime lastBuilt, DateTime lastUpdated, IComponent rootComponent, IEnumerable<Event> recentEvents)
4040
{
4141
ServiceStatus status;
4242
string statusJson;
4343
using (_logger.Scope("Serializing service status."))
4444
{
45-
status = new ServiceStatus(cursor, rootComponent, recentEvents);
45+
status = new ServiceStatus(lastBuilt, lastUpdated, rootComponent, recentEvents);
4646
statusJson = JsonConvert.SerializeObject(status, Settings);
4747
}
4848

src/StatusAggregator/Factory/NuGetServiceComponentFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public IComponent Create()
3434
"",
3535
new IComponent[]
3636
{
37-
new PrimarySecondaryComponent(
37+
new ActivePassiveComponent(
3838
GalleryName,
3939
"Browsing the Gallery website",
4040
new[]
@@ -55,7 +55,7 @@ public IComponent Create()
5555
new LeafComponent(GlobalRegionName, "V3 restore for users outside of China"),
5656
new LeafComponent(ChinaRegionName, "V3 restore for users inside China")
5757
}),
58-
new PrimarySecondaryComponent(
58+
new ActiveActiveComponent(
5959
V2ProtocolName,
6060
"Restore using the V2 API",
6161
new[]
@@ -69,15 +69,15 @@ public IComponent Create()
6969
"Searching for new and existing packages in Visual Studio or the Gallery website",
7070
new[]
7171
{
72-
new PrimarySecondaryComponent(
72+
new ActiveActiveComponent(
7373
GlobalRegionName,
7474
"Search for packages outside China",
7575
new[]
7676
{
7777
new LeafComponent(UsncInstanceName, "Primary region"),
7878
new LeafComponent(UsscInstanceName, "Backup region")
7979
}),
80-
new PrimarySecondaryComponent(
80+
new ActiveActiveComponent(
8181
ChinaRegionName,
8282
"Search for packages inside China",
8383
new[]

src/StatusAggregator/LogEvents.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ public static class LogEvents
66
{
77
public static EventId RegexFailure = new EventId(400, "Failed to parse incident using Regex.");
88
public static EventId ManualChangeFailure = new EventId(401, "Failed to apply a manual change.");
9+
public static EventId IncidentIngestionFailure = new EventId(402, "Failed to update incident API data.");
910
}
1011
}

src/StatusAggregator/Parse/IncidentRegexParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public bool TryParseIncident(Incident incident, out ParsedIncident parsedInciden
5656
return false;
5757
}
5858

59-
_logger.LogInformation("RegEx match result: {MatchResult}", title, match.Success);
59+
_logger.LogInformation("RegEx match result: {MatchResult}", match.Success);
6060
return match.Success && TryParseIncident(incident, match.Groups, out parsedIncident);
6161
}
6262
}

src/StatusAggregator/StatusAggregator.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@
157157
<Version>1.1.1</Version>
158158
</PackageReference>
159159
<PackageReference Include="NuGet.Services.Incidents">
160-
<Version>2.33.0</Version>
160+
<Version>2.38.0</Version>
161161
</PackageReference>
162162
<PackageReference Include="NuGet.Services.Status">
163-
<Version>2.33.0</Version>
163+
<Version>2.38.0</Version>
164164
</PackageReference>
165165
<PackageReference Include="NuGet.Services.Status.Table">
166-
<Version>2.33.0</Version>
166+
<Version>2.38.0</Version>
167167
</PackageReference>
168168
<PackageReference Include="WindowsAzure.Storage">
169169
<Version>9.2.0</Version>

src/StatusAggregator/Update/StatusUpdater.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ namespace StatusAggregator.Update
1313
{
1414
public class StatusUpdater : IStatusUpdater
1515
{
16-
private const string ManualCursorBaseName = "manual";
17-
private const string IncidentCursorName = "incident";
16+
public const string LastUpdatedCursorName = "updated";
1817

1918
private readonly ICursor _cursor;
2019
private readonly IEntityCollector _incidentCollector;
@@ -50,8 +49,17 @@ public async Task Update(DateTime cursor)
5049
await manualStatusChangeCollector.FetchLatest();
5150
}
5251

53-
await _incidentCollector.FetchLatest();
54-
await _activeEventUpdater.UpdateAllAsync(cursor);
52+
try
53+
{
54+
await _incidentCollector.FetchLatest();
55+
await _activeEventUpdater.UpdateAllAsync(cursor);
56+
57+
await _cursor.Set(LastUpdatedCursorName, cursor);
58+
}
59+
catch (Exception e)
60+
{
61+
_logger.LogError(LogEvents.IncidentIngestionFailure, e, "Failed to update incident API data.");
62+
}
5563
}
5664
}
5765

0 commit comments

Comments
 (0)