-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: Added code for Internal-tls #36865
Conversation
/assign @xiaofan-luan @nish112022 please check on the reason of ut failure |
I will help on the review of this pr. |
@xiaofan-luan I have a few questions before I proceed with my changes.
|
paramtable.Init() | ||
validPath := "../../../../configs/cert1/ca.pem" | ||
ctx := context.Background() | ||
client, err := NewClient(ctx, "test", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, here I think I have written the test completely wrong.
I should test the NewClient() with TLS configs before replacing it with mock client.
paramtable.Get().Save(Params.TLSMode.Key, "1") |
This will successfully create the NewClient().
How should I test if the NewClient is behaving in the same manner it is supposed to work?
1 option I can think is of writing a mock datanode server and try to connect to that.Are there any better suggestions in your mind @xiaofan-luan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing you can do is to add an integration test in tests/integration.
You can create a MiniCluster and try to connect between
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through the code in tests/integration. I am seeing a mini cluster already present.
I'll create a separate test suite for internal TLS, including necessary certificates. This suite will cover basic operations like creating collections, inserting data, and running queries to ensure secure communication between nodes.This way we can validate TLS functionality without affecting other test cases.
@xiaofan-luan Can you please take a look here? |
configs/docker-compose.yml
Outdated
@@ -0,0 +1,175 @@ | |||
version: '3.5' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configs folder seems like the wrong place for this docker compose file. There is a folder deployments/docker/cluster-distributed-deployment
which seems to contain Ansible code for deploying Milvus in a distributed fashion, but I'm not sure if that's actively used.
I'd suggest removing this compose file from the PR for now. If we find a good place for it you can always raise another PR.
Similarly, I would also remove the new certs added to configs/cert1 for now, since they're not currently used anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will be removing these certs, docker-compose, yaml for now.These were all part of my test-setup.
internal/distributed/utils/util.go
Outdated
case "querynode": | ||
serverCfg = &Params.QueryNodeGrpcServerCfg | ||
case "rootcoord": | ||
serverCfg = &Params.RootCoordGrpcServerCfg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here is a bit awkward. The startGrpcLoop
function for each of the components calls this function by passing in a string indicating the component name, and then this function uses a switch to decide which component param to use.
However, in milvus.yaml
, you have one common section for internalTLS configs. To match with this I suggest that you do one of the following:
- Remove the common internal TLS parameters from
grpcConfig
and move them tocommonCfg
, or - Create a new config struct (say,
internalTLSConfig
) and add it toComponentParam
One possible drawback of this approach is that you won't be able to specify different certificate paths for the different nodes, but this shouldn't be a problem. If the nodes are deployed in separate containers / machines, the same path can have different certificates, and if the nodes are on the same machine (for example in standalone) a single certificate should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create a struct and do what you suggest, but the TLS configs are also part of the grpc configs. Hence, I added internalTLS configs here.Let me add a new struct to make this better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here is a bit awkward. The
startGrpcLoop
function for each of the components calls this function by passing in a string indicating the component name, and then this function uses a switch to decide which component param to use.However, in
milvus.yaml
, you have one common section for internalTLS configs. To match with this I suggest that you do one of the following:
- Remove the common internal TLS parameters from
grpcConfig
and move them tocommonCfg
, or- Create a new config struct (say,
internalTLSConfig
) and add it toComponentParam
One possible drawback of this approach is that you won't be able to specify different certificate paths for the different nodes, but this shouldn't be a problem. If the nodes are deployed in separate containers / machines, the same path can have different certificates, and if the nodes are on the same machine (for example in standalone) a single certificate should be enough.
Thanks for the comment, I'm just gonna to point out the same thing
pkg/util/paramtable/grpc_param.go
Outdated
return p.IP + ":" + p.InternalPort.GetValue() | ||
} | ||
fmt.Println("address: ", p.Address.GetValue()) | ||
return p.Address.GetValue() + ":" + p.InternalPort.GetValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need separate configurations for p.IP
and p.Address
? Can we reuse the existing configuration p.IP
, with the understanding that you can use a hostname instead of the IP address if desired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm wondering.
what if we simply use ip instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, I have modified the code.
It will pick from the IP configuration from the milvus.yaml
pkg/util/paramtable/grpc_param.go
Outdated
if !p.InternalTLSEnabled.GetAsBool() { | ||
return p.IP + ":" + p.Port.GetValue() | ||
} | ||
fmt.Println("address: ", p.Address.GetValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the fmt.Println
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this config itself.
pkg/util/paramtable/grpc_param.go
Outdated
return p.IP + ":" + p.InternalPort.GetValue() | ||
} | ||
fmt.Println("address: ", p.Address.GetValue()) | ||
return p.Address.GetValue() + ":" + p.InternalPort.GetValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm wondering.
what if we simply use ip instead?
internal/distributed/utils/util.go
Outdated
|
||
if !certPool.AppendCertsFromPEM(b) { | ||
log.Error("credentials: failed to append certificates") | ||
return nil, err // Cert pool is invalid, return nil and the error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
te err will be nil on this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to create error here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a new error here
internal/distributed/utils/util.go
Outdated
log.Error("Unknown NodeType") | ||
return grpc.Creds(nil) | ||
} | ||
certFile := serverCfg.InternalTLSServerPemPath.GetValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use one PemPath for every node?
does it necessary to create a path for each node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified this.I have moved the InternalTLSconfig from grpcconfig to InternalTLSconfig.This has removed the need for a switch statement here.
internal/distributed/utils/util.go
Outdated
case "querynode": | ||
serverCfg = &Params.QueryNodeGrpcServerCfg | ||
case "rootcoord": | ||
serverCfg = &Params.RootCoordGrpcServerCfg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here is a bit awkward. The
startGrpcLoop
function for each of the components calls this function by passing in a string indicating the component name, and then this function uses a switch to decide which component param to use.However, in
milvus.yaml
, you have one common section for internalTLS configs. To match with this I suggest that you do one of the following:
- Remove the common internal TLS parameters from
grpcConfig
and move them tocommonCfg
, or- Create a new config struct (say,
internalTLSConfig
) and add it toComponentParam
One possible drawback of this approach is that you won't be able to specify different certificate paths for the different nodes, but this shouldn't be a problem. If the nodes are deployed in separate containers / machines, the same path can have different certificates, and if the nodes are on the same machine (for example in standalone) a single certificate should be enough.
Thanks for the comment, I'm just gonna to point out the same thing
paramtable.Init() | ||
validPath := "../../../../configs/cert1/ca.pem" | ||
ctx := context.Background() | ||
client, err := NewClient(ctx, "test", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing you can do is to add an integration test in tests/integration.
You can create a MiniCluster and try to connect between
Overall I like this pr, there is something else to point out.
Let me know if anything need to be discussed. Feel free to reach me out at [email protected] and I'd like to discuss on it |
right now there is e2e issue on master need to fixed. please wait and rebase |
4507d2f
to
c4742ff
Compare
c4742ff
to
ab2c254
Compare
@xiaofan-luan |
@xiaofan-luan
Sure, we can take this up in a separate effort and work on this |
e1a9835
to
64470c2
Compare
@nish112022 Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco. |
97b7ac2
to
f783501
Compare
Signed-off-by: Nischay Yadav <[email protected]>
Signed-off-by: Nischay <[email protected]>
Signed-off-by: Nischay <[email protected]>
Signed-off-by: Nischay <[email protected]>
Signed-off-by: Nischay <[email protected]>
Signed-off-by: Nischay <[email protected]>
f783501
to
2a62871
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #36865 +/- ##
==========================================
- Coverage 82.88% 81.03% -1.85%
==========================================
Files 1067 1356 +289
Lines 164522 190146 +25624
==========================================
+ Hits 136362 154084 +17722
- Misses 22698 30592 +7894
- Partials 5462 5470 +8
|
Hi @xiaofan-luan, I have marked this as ready for review. Please take a look at your convenience. |
@nish112022 E2e jenkins job failed, comment |
/run-cpu-e2e |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nish112022, xiaofan-luan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@nish112022 Next step is we need to document on all to enable this . @haorenfsa could you work with nish to support tls in both k8s operator and Helm chart? |
I will start looking into the k8s operator and helm chart.I am not very familiar with those. |
Thanks for the contribution. |
issue : milvus-io#36864 I have a few questions regarding my approach.I will consolidate them here for feedback and review.Thanks --------- Signed-off-by: Nischay Yadav <[email protected]> Signed-off-by: Nischay <[email protected]>
issue : #36864
I have a few questions regarding my approach.I will consolidate them here for feedback and review.Thanks