Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
95bf9179
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
95bf9179
编写于
5月 18, 2022
作者:
Z
zhuwenxing
提交者:
GitHub
5月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[skip e2e]Add util to get milvus instance name (#17081)
Signed-off-by:
N
zhuwenxing
<
wenxing.zhu@zilliz.com
>
上级
694f8903
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
7 deletion
+60
-7
tests/python_client/common/milvus_sys.py
tests/python_client/common/milvus_sys.py
+15
-4
tests/python_client/utils/util_k8s.py
tests/python_client/utils/util_k8s.py
+45
-3
未找到文件。
tests/python_client/common/milvus_sys.py
浏览文件 @
95bf9179
...
...
@@ -28,6 +28,11 @@ class MilvusSys:
"""get the first node's build version as milvus build version"""
return
self
.
nodes
[
0
].
get
(
'infos'
).
get
(
'system_info'
).
get
(
'system_version'
)
@
property
def
build_time
(
self
):
"""get the first node's build time as milvus build time"""
return
self
.
nodes
[
0
].
get
(
'infos'
).
get
(
'system_info'
).
get
(
'build_time'
)
@
property
def
deploy_mode
(
self
):
"""get the first node's deploy_mode as milvus deploy_mode"""
...
...
@@ -39,9 +44,8 @@ class MilvusSys:
get simd type that milvus is running against
return the first query node's simd type
"""
for
node
in
self
.
nodes
:
if
'QueryNode'
==
node
.
get
(
'infos'
).
get
(
'type'
):
return
node
.
get
(
'infos'
).
get
(
'system_configurations'
).
get
(
'simd_type'
)
for
node
in
self
.
query_nodes
:
return
node
.
get
(
'infos'
).
get
(
'system_configurations'
).
get
(
'simd_type'
)
raise
Exception
(
"No query node found"
)
@
property
...
...
@@ -83,7 +87,9 @@ class MilvusSys:
@
property
def
nodes
(
self
):
"""get all the nodes in Milvus deployment"""
return
json
.
loads
(
self
.
sys_info
.
response
).
get
(
'nodes_info'
)
all_nodes
=
json
.
loads
(
self
.
sys_info
.
response
).
get
(
'nodes_info'
)
online_nodes
=
[
node
for
node
in
all_nodes
if
node
[
"infos"
][
"has_error"
]
is
False
]
return
online_nodes
def
get_nodes_by_type
(
self
,
node_type
=
None
):
"""get milvus nodes by node type"""
...
...
@@ -93,3 +99,8 @@ class MilvusSys:
if
str
(
node_type
).
lower
()
==
str
(
node
.
get
(
'infos'
).
get
(
'type'
)).
lower
():
target_nodes
.
append
(
node
)
return
target_nodes
if
__name__
==
'__main__'
:
connections
.
connect
(
host
=
"10.96.250.111"
,
port
=
"19530"
)
ms
=
MilvusSys
()
tests/python_client/utils/util_k8s.py
浏览文件 @
95bf9179
import
os.path
import
time
from
pymilvus
import
connections
from
kubernetes
import
client
,
config
from
kubernetes.client.rest
import
ApiException
from
common.milvus_sys
import
MilvusSys
...
...
@@ -41,12 +42,12 @@ def wait_pods_ready(namespace, label_selector, expected_num=None, timeout=360):
all_pos_ready_flag
=
False
break
for
c
in
item
.
status
.
container_statuses
:
log
.
info
(
f
"
{
c
.
name
}
status is
{
c
.
ready
}
"
)
log
.
debug
(
f
"
{
c
.
name
}
status is
{
c
.
ready
}
"
)
if
c
.
ready
is
False
:
all_pos_ready_flag
=
False
break
if
not
all_pos_ready_flag
:
log
.
info
(
"all pods are not ready, please wait"
)
log
.
debug
(
"all pods are not ready, please wait"
)
time
.
sleep
(
30
)
time_cnt
+=
30
if
all_pos_ready_flag
:
...
...
@@ -135,6 +136,46 @@ def get_querynode_id_pod_pairs(namespace, label_selector):
return
querynode_id_pod_pair
def
get_milvus_instance_name
(
namespace
,
host
,
port
=
"19530"
):
"""
get milvus instance name after connection
:param namespace: the namespace where the release
:type namespace: str
:param host: milvus host ip
:type host: str
:param port: milvus port
:type port: str
:example:
>>> milvus_instance_name = get_milvus_instance_name("chaos-testing", "10.96.250.111")
"milvus-multi-querynode"
"""
connections
.
connect
(
host
=
host
,
port
=
port
)
ms
=
MilvusSys
()
query_node_ip
=
ms
.
query_nodes
[
0
][
"infos"
][
'hardware_infos'
][
"ip"
].
split
(
":"
)[
0
]
pod_name
=
""
if
ms
.
deploy_mode
==
"STANDALONE"
:
# get all pods which label is app.kubernetes.io/name=milvus and component=standalone
ip_name_pairs
=
get_pod_ip_name_pairs
(
namespace
,
"app.kubernetes.io/name=milvus, component=standalone"
)
pod_name
=
ip_name_pairs
[
query_node_ip
]
if
ms
.
deploy_mode
==
"DISTRIBUTED"
:
# get all pods which label is app.kubernetes.io/name=milvus and component=querynode
ip_name_pairs
=
get_pod_ip_name_pairs
(
namespace
,
"app.kubernetes.io/name=milvus, component=querynode"
)
pod_name
=
ip_name_pairs
[
query_node_ip
]
config
.
load_kube_config
()
api_instance
=
client
.
CoreV1Api
()
try
:
api_response
=
api_instance
.
read_namespaced_pod
(
namespace
=
namespace
,
name
=
pod_name
)
except
ApiException
as
e
:
log
.
error
(
"Exception when calling CoreV1Api->list_namespaced_pod: %s
\n
"
%
e
)
raise
Exception
(
str
(
e
))
milvus_instance_name
=
api_response
.
metadata
.
labels
[
"app.kubernetes.io/instance"
]
return
milvus_instance_name
def
export_pod_logs
(
namespace
,
label_selector
,
release_name
=
None
):
"""
export pod logs with label selector to '/tmp/milvus'
...
...
@@ -197,7 +238,8 @@ def read_pod_log(namespace, label_selector, release_name):
if
__name__
==
'__main__'
:
label
=
"app.kubernetes.io/instance=milvus-load-balance, component=querynode"
label
=
"app.kubernetes.io/name=milvus, component=querynode"
instance_name
=
get_milvus_instance_name
(
"chaos-testing"
,
"10.96.250.111"
)
res
=
get_pod_list
(
"chaos-testing"
,
label_selector
=
label
)
m
=
get_pod_ip_name_pairs
(
"chaos-testing"
,
label_selector
=
label
)
export_pod_logs
(
namespace
=
'chaos-testing'
,
label_selector
=
label
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录