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

Adds Milvus to the Aspire hosting/component packages #4179

Merged
merged 21 commits into from
Jun 4, 2024
Merged

Conversation

timheuer
Copy link
Member

@timheuer timheuer commented May 15, 2024

Adds the Milvus vector database to Aspire.

  • Hosting component using container standalone
  • Client component using C# Milvus.Client
  • Hosting/Component initial tests
  • Added playground app (use api.http to run the steps) - uses code samples from C# SDK
  • Adds the Attu web admin experience (excluded from publish manifest)

Requires that a parameter exists for the root auth api key
No healthchecks/tracing/metrics available in the C# Milvus.Client

2024-05-14_12-00-12.mp4

/cc @roji @luisquintanilla

Microsoft Reviewers: Open in CodeFlow

Aspire.sln Outdated
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Consumer", "playground\kafka\Consumer\Consumer.csproj", "{7AA4C56C-3BB2-4FF0-BB03-F3F0D6A4FDAB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Consumer", "playground\kafka\Consumer\Consumer.csproj", "{7AA4C56C-3BB2-4FF0-BB03-F3F0D6A4FDAB}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why these keep getting updated? Seen it in other PRs too. Result of a merge or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a note in to the project team -- I noticed this a while back...I can't explain either :-(

NuGet.config Outdated Show resolved Hide resolved
@mitchdenny
Copy link
Member

This is looking pretty good. Mostly just some minor things and questions. @eerhardt for a once over for the component side of things. I gave it a once over but he is more attuned to that side of things.

@mitchdenny
Copy link
Member

One thing that I'm thinking about is allowing unauthenticated access to Attu?

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice to see this!

@timheuer
Copy link
Member Author

One thing that I'm thinking about is allowing unauthenticated access to Attu?

Attu requires authenticated access to the Milvus instance -- much like things like PgAdmin have a login prompt as well. Is that what you're referring to? Attu starts with a login requirement to an instance of Milvus, it isn't open-ended.

Directory.Packages.props Show resolved Hide resolved
NuGet.config Outdated Show resolved Hide resolved
playground/milvus/MilvusPlayground.ApiService/Program.cs Outdated Show resolved Hide resolved
@@ -0,0 +1,12 @@
var builder = DistributedApplication.CreateBuilder(args);

var token = builder.AddParameter("milvusauth", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Can we just generate an auth token instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. there is only one user in a default Milvus container (root:Milvus). This cannot be configured presently via environment variables or anything and can only be configured after the fact (or additional users after the fact). See: milvus-io/milvus#33058 and milvus-io/milvus#33032 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this code going to work then?

var tokenParameter = apiKey?.Resource ??
ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-Key", special: false);
var milvus = new MilvusServerResource(name, tokenParameter);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me thinking aloud why I kept this in...

It is possible to reset the root token. But right now it has to be done after the fact. So in theory someone could do a data volume, have a script (or some other client operation) that changes the root login (or adds another user), and then this would need to be changed (they would populate the parameter. Correct here that the CreateDefaultPasswordParameter wouldn't really work in this instance. I was also trying to avoid hard-coding the default root creds here.

To me the ideal would look like apiKey?.Resource ?? DefaultMilvusApiKeyParameter - per discussion in teams channels, there is no easy way to create a ParameterResource with a string value default.

Thoughts welcome here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to remove generation, made the apiKey notnull, not burning in the hard-coded default in code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timheuer - thinking more about this - how is this going to work in a deployed/production environment? If I use azd to deploy an app that has a Milvus resource, will the ApiKey always be root:Milvus even in a deployed environment? That doesn't seem secure.

src/Aspire.Hosting.Milvus/MilvusContainerImageTags.cs Outdated Show resolved Hide resolved
src/Aspire.Hosting.Milvus/MilvusServerResource.cs Outdated Show resolved Hide resolved
src/Components/Aspire.Milvus.Client/README.md Outdated Show resolved Hide resolved
tests/Aspire.Milvus.Client.Tests/AspireMilvusHelpers.cs Outdated Show resolved Hide resolved
tests/Aspire.Milvus.Client.Tests/MilvusContainerFixture.cs Outdated Show resolved Hide resolved
Comment on lines +47 to +50
protected override void TriggerActivity(MilvusClient service)
{
service.GetVersionAsync().Wait();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tracing with Milvus?

What is the tracing, metrics, and health checks plan for this component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning on logging issues on the component to add some of these. @roji do you know if these may already be in the works?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HealthCheck added, tracing/metrics logged at Milvus.Client repo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracking issue on the Milvus SDK side is milvus-io/milvus-sdk-csharp#85.

I'm planning on adding tracing support there, but it may take me a bit of time before I get around to it... Re metrics, I think it's more appropriate to get them from Milvus itself (the server), which emits them - see the issue above for some discussion on that. We may want to have a more general discussion on the client vs. server preference for metrics.

- Added health check
- Added example in doc comments
- Modified tests to use testcontainer
- Added WithDataBindMount
@eerhardt
Copy link
Member

Can you also add some end-to-end tests?

[InlineData(TestResourceNames.mongodb)]
[InlineData(TestResourceNames.mysql)]
[InlineData(TestResourceNames.efmysql)]
[InlineData(TestResourceNames.postgres)]
[InlineData(TestResourceNames.efnpgsql)]
[InlineData(TestResourceNames.rabbitmq)]
[InlineData(TestResourceNames.redis)]
[InlineData(TestResourceNames.garnet)]
[InlineData(TestResourceNames.sqlserver)]
public Task VerifyComponentWorks(TestResourceNames resourceName)

See #3839 for an example.

@timheuer timheuer marked this pull request as ready for review May 22, 2024 22:11
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

playground/milvus/MilvusPlayground.ApiService/Program.cs Outdated Show resolved Hide resolved

private static void ConfigureAttuContainer(EnvironmentCallbackContext context, MilvusServerResource resource)
{
context.EnvironmentVariables.Add("MILVUS_URL", $"{resource.PrimaryEndpoint.Scheme}://{resource.PrimaryEndpoint.ContainerHost}:{resource.PrimaryEndpoint.Port}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
context.EnvironmentVariables.Add("MILVUS_URL", $"{resource.PrimaryEndpoint.Scheme}://{resource.PrimaryEndpoint.ContainerHost}:{resource.PrimaryEndpoint.Port}");
context.EnvironmentVariables.Add("MILVUS_URL", $"{resource.PrimaryEndpoint.Property(EndpointProperty.Url)}");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a correct edit @eerhardt. See: https://github.com/dotnet/aspire/blob/main/src/Aspire.Hosting.MySql/PhpMyAdminConfigWriterHook.cs#L37 (and Postgres as well) -- for the local dev experience and the admin tools, they are containers needing to access containers. The proxy ports don't help and need the container host network.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidfowl @mitchdenny - would it make sense to make a "ContainerHostUrl" property on an Endpoint? That way would could simplify code like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we will be able to use the .Url property when this is addressed:

#3735

@timheuer
Copy link
Member Author

timheuer commented Jun 3, 2024

@eerhardt any other feedback to get this over the last mile?

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution, @timheuer!

@eerhardt eerhardt enabled auto-merge (squash) June 4, 2024 17:39
@eerhardt eerhardt merged commit 4a3a1da into main Jun 4, 2024
8 checks passed
@eerhardt eerhardt deleted the timheuer/milvus branch June 4, 2024 18:29
@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants