-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 728101: BlobLifetimeManager supports multiple universes/nam…
…espaces, reading from the change feed, and checkpointing As preparation for checkpointing, which requires that garbage collection happens for the whole storage account at once, it makes sense to first support garbage collecting multiple namespaces/universes in a single garbage collection run. The idea is that instead of accessing the DB directly, there is an IAccessor, which limits the view of the database to only a given namespace. In practice, what this means is that each accessor will have a unique set of RocksDb column families that it accesses. Other than that, the logic to create/manage the database stays the same. Another change is that we can now update our view of the world in subsequent runs via reading Azure Storage's change feed. This is extremely important since otherwise, nothing works: on the first run, since we touch everything, nothing is evictable; and on the second run, such a long time has passed that without updating our view of things, we might be deleting blobs with new references. Finally, after both these changes, I also implemented checkpointing. The checkpoint and all its data will live in different containers in the 0th shard of the cache, as different-sized caches _are different caches_, regardless of whether they share accounts. Ideally, we won't have this ever since we're the ones resharding, but even today we already have that problem since some of our tests are not using all 100 accounts we've provisioned.
- Loading branch information
1 parent
b64183f
commit 911efd8
Showing
37 changed files
with
2,184 additions
and
625 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
30 changes: 30 additions & 0 deletions
30
Public/Src/Cache/ContentStore/Distributed/Blob/AbsoluteBlobPath.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,30 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace BuildXL.Cache.ContentStore.Distributed.Blob | ||
{ | ||
/// <summary> | ||
/// This absolute path is gotten from the Azure Blob change feed. It uniquely identifies a blob within the cache. | ||
/// </summary> | ||
public readonly record struct AbsoluteBlobPath(BlobCacheStorageAccountName Account, BlobCacheContainerName Container, BlobPath Path) | ||
{ | ||
private readonly static Regex BlobChangeFeedEventSubjectRegex = new(@"/blobServices/default/containers/(?<container>[^/]+)/blobs/(?<path>.+)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); | ||
|
||
public static AbsoluteBlobPath ParseFromChangeEventSubject(BlobCacheStorageAccountName account, string subject) | ||
{ | ||
var match = BlobChangeFeedEventSubjectRegex.Match(subject); | ||
if (!match.Success) | ||
{ | ||
throw new ArgumentException($"Failed to match {nameof(BlobChangeFeedEventSubjectRegex)} to {subject}", nameof(subject)); | ||
} | ||
|
||
var container = BlobCacheContainerName.Parse(match.Groups["container"].Value); | ||
var path = new BlobPath(match.Groups["path"].Value, relative: false); | ||
|
||
return new(Account: account, Container: container, Path: path); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Public/Src/Cache/ContentStore/Distributed/Blob/BlobNamespaceId.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,14 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace BuildXL.Cache.ContentStore.Distributed.Blob | ||
{ | ||
/// <summary> | ||
/// This uniquely describes a namespace in a blob cache. Each namespace is garbage-collected | ||
/// as a separate cache from other namespaces | ||
/// </summary> | ||
public readonly record struct BlobNamespaceId(string Universe, string Namespace) | ||
{ | ||
public override string ToString() => $"{Universe}-{Namespace}"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Public/Src/Cache/ContentStore/Distributed/Blob/EnvironmentVariableCacheSecretsProvider.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,36 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using BuildXL.Cache.ContentStore.Interfaces.Secrets; | ||
|
||
#nullable enable | ||
|
||
namespace BuildXL.Cache.ContentStore.Distributed.Blob | ||
{ | ||
public class EnvironmentVariableCacheSecretsProvider : StaticBlobCacheSecretsProvider | ||
{ | ||
public EnvironmentVariableCacheSecretsProvider(string environmentVariableName) | ||
: base(ExtractCredsFromEnvironmentVariable(environmentVariableName)) | ||
{ | ||
} | ||
|
||
public static Dictionary<BlobCacheStorageAccountName, AzureStorageCredentials> ExtractCredsFromEnvironmentVariable(string environmentVariableName) | ||
{ | ||
var connectionStringsString = Environment.GetEnvironmentVariable(environmentVariableName); | ||
if (string.IsNullOrEmpty(connectionStringsString)) | ||
{ | ||
throw new ArgumentException($"Connections strings for the L3 cache must be provided via the {environmentVariableName} environment variable " + | ||
$"in the format of comma-separated strings."); | ||
} | ||
|
||
var connectionStrings = connectionStringsString.Split(','); | ||
var creds = connectionStrings.Select(connString => new AzureStorageCredentials(new PlainTextSecret(connString))).ToArray(); | ||
return creds.ToDictionary( | ||
cred => BlobCacheStorageAccountName.Parse(cred.GetAccountName()), | ||
cred => cred); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.