Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question / Guidance: MinIO Implementation #108

Open
Cjewett opened this issue Nov 29, 2024 · 1 comment
Open

Question / Guidance: MinIO Implementation #108

Cjewett opened this issue Nov 29, 2024 · 1 comment

Comments

@Cjewett
Copy link

Cjewett commented Nov 29, 2024

After reading more about MSBuildCache and BuildXL I wanted to ask a few questions to see if implementing MinIO as a cache is feasible and at what level it should be implemented.

  • Is the expectation of this repository to hide the internals of BuildXL? The reason I ask is BuildXL seems to be on GitHub but has a decent amount of internal vs public stuff going on. Not clear to me if extending functionality from that repository is recommended.
  • If it is recommended to extend functionality from that repository any guidance on a Minio approach? This is what I've currently got in my notes so far:
    • Use AzureBlobStorage as an example.
    • Careful of classes that seem generic but have Azure specific functionality. May not be able to re-use as much as initially hoped.
    • Create MSBuildCacheMinioStoragePlugin.cs
    • MSBuildCacheMinioStoragePlugin.cs will implement CreateCacheClientAsync that returns a CasCacheClient to satisfy ICacheClient requirement.
    • The CasCacheClient expects a local cache and remote cache. The local cache is already handled. The remote cache must be a Minio compatible remote cache implementation.
    • To create a Minio compatible remote cache client we must implement:
      • MinioContentStore to satisfy IContentStore requirement.
      • MinioContentSession to satisfy IContentSession requirement.
      • MinioContentStore and MinioContentSession will be injected into OneLevelCache and "just work" given those new Minio classes are implemented correctly.
      • MinioMetadataStore to satisfy IMetadataStore requirement.
      • MinioMetadataStore will be injected into MetadataStoreMemoizationDatabase. DatabaseMemoizationStore will "just work" given new Minio classes are implemented correctly.
      • IPublishingStore and IPublishingSession looks like they need to be implemented but ran out of time during investigation. Look later to determine requirements.
      • IBlobCacheTopology does not seem required but might want to mimic flow anyways to keep things the same.
    • Overall very involved. Overhead of learning BuildXL is very high. Testing / debuggability also seems difficult.

Does everything around BuildXL and having to extend that sound correct if we want a Minio / S3 implementation? Am I overstating or understating how involved this is?

Any guidance would be appreciated!

@dfederm
Copy link
Member

dfederm commented Jan 2, 2025

Is the expectation of this repository to hide the internals of BuildXL?

Yes, for the most part. BuildXL is an implementation detail for MSBuildCache.

If it is recommended to extend functionality from that repository any guidance on a Minio approach?

You should implement a new cache storage backend by referencing Microsoft.MSBuildCache.Common. You can use the various other implementations in this repo as a guide. This will maintain all the core logic such as fingerprinting but allow you to provide a different mechanism for actually storing the cache metadata and content.

Specifically, you should subclass CacheClient, not CasCacheClient, which is tied to BuildXL stuff. The AzurePipelines implementation would probably be the be reference here.

So just need to provide implementations for these methods:

    protected abstract Task<OpenStreamResult> OpenStreamAsync(
        Context context,
        ContentHash contentHash,
        CancellationToken cancellationToken);

    protected abstract Task AddNodeAsync(
        Context context,
        StrongFingerprint fingerprint,
        IReadOnlyDictionary<string, ContentHash> outputs,
        (ContentHash hash, byte[] bytes) nodeBuildResultBytes,
        (ContentHash hash, byte[] bytes)? pathSetBytes,
        CancellationToken cancellationToken);

    protected abstract IAsyncEnumerable<Selector> GetSelectors(
        Context context,
        WeakFingerprint fingerprint,
        CancellationToken cancellationToken);

    protected abstract Task<ICacheEntry?> GetCacheEntryAsync(
        Context context,
        StrongFingerprint cacheStrongFingerprint,
        CancellationToken cancellationToken);

You can drop down to implementing ICacheClient fully if you wish, but that may be a bit more involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants