Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Revalidation] Add Admin Panel (#6172)
This change adds two features: * A revalidation state service - This service allows parallel updates to the state. This is used by the Gallery, and later, the revalidation job for things like the killswitch and the desired revalidation rate. * An admin UI to stop/start the revalidation job. Addresses https://github.com/NuGet/Engineering/issues/1437
- Loading branch information
1 parent
68cee3e
commit 04f2f6e
Showing
27 changed files
with
1,084 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/NuGetGallery.Core/Extensions/StorageExceptionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Net; | ||
using Microsoft.WindowsAzure.Storage; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public static class StorageExceptionExtensions | ||
{ | ||
public static bool IsFileAlreadyExistsException(this StorageException e) | ||
{ | ||
return e?.RequestInformation?.HttpStatusCode == (int?)HttpStatusCode.Conflict; | ||
} | ||
|
||
public static bool IsPreconditionFailedException(this StorageException e) | ||
{ | ||
return e?.RequestInformation?.HttpStatusCode == (int?)HttpStatusCode.PreconditionFailed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/NuGetGallery.Core/Services/IRevalidationStateService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public interface IRevalidationStateService | ||
{ | ||
/// <summary> | ||
/// Get the latest state. Throws if the state blob cannot be found. | ||
/// </summary> | ||
/// <returns>The latest state.</returns> | ||
Task<RevalidationState> GetStateAsync(); | ||
|
||
/// <summary> | ||
/// Attempt to update the state atomically. Throws if the update fails. | ||
/// </summary> | ||
/// <param name="updateAction">The action used to update the state.</param> | ||
/// <returns>A task that completes once the state has been updated.</returns> | ||
Task UpdateStateAsync(Action<RevalidationState> updateAction); | ||
|
||
/// <summary> | ||
/// Attempt to update the state atomically. Throws is the update fails. | ||
/// </summary> | ||
/// <param name="updateAction">The callback that updates the state. Changes are only persisted if the callback returns true</param> | ||
/// <returns>The updated state.</returns> | ||
Task<RevalidationState> MaybeUpdateStateAsync(Func<RevalidationState, bool> updateAction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGetGallery | ||
{ | ||
/// <summary> | ||
/// The settings for the revalidation job. | ||
/// </summary> | ||
public class RevalidationState | ||
{ | ||
/// <summary> | ||
/// Whether the revalidation job has been deactivated. | ||
/// </summary> | ||
public bool IsKillswitchActive { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Whether the revalidation job's state has been initialized. | ||
/// </summary> | ||
public bool IsInitialized { get; set; } = false; | ||
|
||
/// <summary> | ||
/// The desired number maximal number of package events (pushes, lists, unlists, revalidations) | ||
/// per hour. | ||
/// </summary> | ||
public int DesiredPackageEventRate { get; set; } | ||
} | ||
} |
Oops, something went wrong.