pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

[Bug]: [milvus_client][doc] Create collection failed when granting a role with privilege CreateCollection

Open NicoYuan1986 opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Create collection failed when granting a role with privilege CreateCollection.

[2024-02-01 11:36:58 - DEBUG - ci_test]: (api_request)  : [MilvusClient.create_collection] args: ['test_zbhT0wDg', 128], kwargs: {'consistency_level': 'Strong', 'timeout': 120} (api_request.py:62)
[2024-02-01 11:36:58 - DEBUG - pymilvus.milvus_client.milvus_client]: Successfully created collection: test_zbhT0wDg (milvus_client.py:136)
[2024-02-01 11:36:58 - ERROR - pymilvus.decorators]: grpc RpcError: [create_index], <_MultiThreadedRendezvous: StatusCode.PERMISSION_DENIED, PrivilegeCreateIndex: permission deny to user_RFqP0r7J>, <Time:{'RPC start': '2024-02-01 11:36:58.713369', 'gRPC error': '2024-02-01 11:36:58.753124'}> (decorators.py:145)
[2024-02-01 11:36:58 - ERROR - pymilvus.milvus_client.milvus_client]: Failed to create an index on collection: test_zbhT0wDg (milvus_client.py:179)
[2024-02-01 11:36:58 - ERROR - ci_test]: Traceback (most recent call last):
  File "/Users/zilliz/nico/milvus/tests/python_client/utils/api_request.py", line 32, in inner_wrapper
    res = func(*args, **_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/nico/milvus/tests/python_client/utils/api_request.py", line 63, in api_request
    return func(*arg, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 82, in create_collection
    return self._fast_create_collection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 147, in _fast_create_collection
    self.create_index(collection_name, index_params, timeout=timeout)
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 158, in create_index
    self._create_index(collection_name, index_param, timeout=timeout, **kwargs)
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 180, in _create_index
    raise ex from ex
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/milvus_client/milvus_client.py", line 169, in _create_index
    conn.create_index(
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/decorators.py", line 149, in handler
    raise e from e
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/decorators.py", line 131, in handler
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/decorators.py", line 170, in handler
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/decorators.py", line 85, in handler
    raise e from e
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/decorators.py", line 74, in handler
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 934, in create_index
    status = future.result()
             ^^^^^^^^^^^^^^^
  File "/Users/zilliz/virtual-environment/milvus/lib/python3.11/site-packages/grpc/_channel.py", line 797, in result
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.PERMISSION_DENIED
	details = "PrivilegeCreateIndex: permission deny to user_RFqP0r7J"
	debug_error_string = "UNKNOWN:Error received from peer ipv4:10.102.9.164:19530 {created_time:"2024-02-01T11:36:58.747062+08:00", grpc_status:7, grpc_message:"PrivilegeCreateIndex: permission deny to user_RFqP0r7J"}"
>
 (api_request.py:45)
[2024-02-01 11:36:58 - ERROR - ci_test]: (api_response) : <_MultiThreadedRendezvous of RPC that terminated with:
	status = StatusCode.PERMISSION_DENIED
	details = "PrivilegeCreateIndex: permission deny to user_RFqP0r7J"
	debug_error_string = "UNKNOWN:Error received from peer ipv4:10.102.9.164:19530 {created_time:"2024-02-01T11:36:58.747062+08:00", grpc_sta...... (api_request.py:46)

Expected Behavior

create successfully

Steps/Code To Reproduce behavior

1. create a role and a user in it
2. grant the role with CreateCollection
3. create collection: client.create_collection(coll_name, default_dim, consistency_level="Strong") -> ❌

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0): master-20240129-033eae9e
- Pymilvus version: 2.4.0rc24
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

NicoYuan1986 avatar Feb 01 '24 03:02 NicoYuan1986

image it seems no create index privilege

SimFG avatar Feb 01 '24 03:02 SimFG

Certainly. However, it might cause confusion for users.

From users' point of view, they have granted the privilege to create a collection, and then they simply call an interface named 'create_collection'. Logically, it should be successful.

create index is unexpected for it is not mentioned.

NicoYuan1986 avatar Feb 01 '24 11:02 NicoYuan1986

/assign @czs007

binbinlv avatar Feb 02 '24 02:02 binbinlv

image it seems no create index privilege

@SimFG How about we use the associated privilege function you added earlier? You create an index when you can create a collection.

czs007 avatar Feb 02 '24 02:02 czs007