From 0ccd87828f523fae142b77f602db9c69725e2457 Mon Sep 17 00:00:00 2001 From: wei liu Date: Tue, 24 Dec 2024 13:48:41 +0800 Subject: [PATCH] fix: grant ManualCompact api doesn't work (#2396) (#2508) issue: milvus-io/milvus#38086 pr: #2396 cause RBAC require to check collection name, but ManualCompact rpc pass collection id in request, so grant ManualCompact api doesn't work. This PR refine compact api impl to pass collection name in request. Signed-off-by: Wei Liu --- pymilvus/client/grpc_handler.py | 3 ++- pymilvus/client/prepare.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index cc7915c06..e9677dd2c 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1644,12 +1644,13 @@ def compact( timeout: Optional[float] = None, **kwargs, ) -> int: + # should be removed, but to be compatible with old milvus server, keep it for now. request = Prepare.describe_collection_request(collection_name) rf = self._stub.DescribeCollection.future(request, timeout=timeout) response = rf.result() check_status(response.status) - req = Prepare.manual_compaction(response.collectionID, is_clustering) + req = Prepare.manual_compaction(response.collectionID, collection_name, is_clustering) future = self._stub.ManualCompaction.future(req, timeout=timeout) response = future.result() check_status(response.status) diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 465667f0d..1630f4cc6 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -1180,7 +1180,7 @@ def load_balance_request( ) @classmethod - def manual_compaction(cls, collection_id: int, is_clustering: bool): + def manual_compaction(cls, collection_id: int, collection_name: str, is_clustering: bool): if collection_id is None or not isinstance(collection_id, int): raise ParamError(message=f"collection_id value {collection_id} is illegal") @@ -1189,6 +1189,7 @@ def manual_compaction(cls, collection_id: int, is_clustering: bool): request = milvus_types.ManualCompactionRequest() request.collectionID = collection_id + request.collection_name = collection_name request.majorCompaction = is_clustering return request