Skip to content

Commit

Permalink
fix: grant ManualCompact api doesn't work (#2396)
Browse files Browse the repository at this point in the history
issue: milvus-io/milvus#38086
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 <[email protected]>
  • Loading branch information
weiliu1031 committed Dec 24, 2024
1 parent 7951839 commit 7edd2c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1652,12 +1652,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)
Expand Down
3 changes: 2 additions & 1 deletion pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,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")

Expand All @@ -1339,6 +1339,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
Expand Down

0 comments on commit 7edd2c1

Please sign in to comment.