mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
[skip e2e] Add log export for milvus installed by operator (#20982)
Signed-off-by: Bennu-Li <yunmei.li@zilliz.com> Signed-off-by: Bennu-Li <yunmei.li@zilliz.com>
This commit is contained in:
parent
43dce09020
commit
ab801a1d67
@ -16,44 +16,49 @@ For better tracking and debugging Milvus, the script `export-milvus-log.sh` is p
|
|||||||
| ---------- | ------------------------------------------------- | ------------ |
|
| ---------- | ------------------------------------------------- | ------------ |
|
||||||
| i | Specify the milvus instance name | None |
|
| i | Specify the milvus instance name | None |
|
||||||
| n | Specify the namespace that milvus is installed in | default |
|
| n | Specify the namespace that milvus is installed in | default |
|
||||||
| p | Specify the log storage path | ./milvus-log |
|
| d | Specify the log storage dir | ./milvus-log |
|
||||||
| e | Export etcd logs | false |
|
| e | Export etcd logs | false |
|
||||||
| m | Export Minio logs | false |
|
| m | Export Minio logs | false |
|
||||||
| u | Export pulsar logs | false |
|
| p | Export pulsar logs | false |
|
||||||
| k | Export Kafka logs | False |
|
| k | Export Kafka logs | False |
|
||||||
| s | Only return logs newer than a relative duration like 5s, 2m,or 3h. Defaults to all logs | all |
|
| s | Only return logs newer than a relative duration like 5s, 2m,or 3h. Defaults to all logs | all |
|
||||||
|
|o |If milvus installed by milvus-operator |false |
|
||||||
> By default, the script only exports the logs of the Milvus component.
|
> By default, the script only exports the logs of the Milvus component.
|
||||||
>
|
>
|
||||||
> If you need to export the logs of etcd, minio, and pulsar components, you need to add the parameters -e, -m, -u.
|
> If you need to export the logs of etcd, minio, and pulsar components, you need to add the parameters -e, -m, -p.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1. Milvus instance name is required to be specified
|
1. Milvus instance name is required to be specified
|
||||||
|
If Milvus installed by helm, export logs by followings:
|
||||||
```shell
|
```shell
|
||||||
./export-milvus-log.sh -i my-release
|
./export-milvus-log.sh -i my-release
|
||||||
```
|
```
|
||||||
|
If Milvus installed by Milvus operator, flag `-o` is required to export the logs:
|
||||||
|
```shell
|
||||||
|
./export-milvus-log.sh -i my-release -o
|
||||||
|
```
|
||||||
|
|
||||||
> This command will generate a directory named milvus-log in the current directory.
|
> This command will generate a directory named milvus-log in the current directory.
|
||||||
> For a pod that have not been restarted, the command will generate a log named ${podname}.log for the pod and store it in `milvus-log`.
|
> For a pod that have not been restarted, the command will generate a log named ${podname}.log for the pod and store it in `milvus-log`.
|
||||||
> For a pod that has been restarted, this command will generate a log named ${podname}.log and a log ${podname}-pre.log for the pod.
|
> For a pod that has been restarted, this command will generate a log named ${podname}.log and a log ${podname}-pre.log for the pod.
|
||||||
|
|
||||||
2. If your milvus is not installed in the k8s default namespace, please specify namespace with `-n`. You can also customize the log storage path with `-p`.
|
2. If your milvus is not installed in the k8s default namespace, please specify namespace with `-n`. You can also customize the log storage path with `-d`.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
./export-milvus-log.sh -i my-release -n milvus -p ./logs
|
./export-milvus-log.sh -i my-release -n milvus -d ./logs
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Export the logs of milvus, etcd, minio, and pulsar components.
|
3. Export the logs of milvus, etcd, minio, and pulsar components.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
./export-milvus-log.sh -i my-release -n milvus -p ./logs -e -m -u
|
./export-milvus-log.sh -i my-release -n milvus -d ./logs -e -m -p
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Export the logs of milvus and Kafka components.
|
4. Export the logs of milvus and Kafka components.
|
||||||
|
|
||||||
```
|
```
|
||||||
./export-milvus-log.sh -i my-release -n milvus -p ./logs -k
|
./export-milvus-log.sh -i my-release -n milvus -d ./logs -k
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Export the logs for only latest 24h.
|
5. Export the logs for only latest 24h.
|
||||||
|
|||||||
@ -9,24 +9,26 @@ minio="false"
|
|||||||
pulsar="false"
|
pulsar="false"
|
||||||
kafka="false"
|
kafka="false"
|
||||||
since_args=""
|
since_args=""
|
||||||
|
operator="false"
|
||||||
#-n namespace: The namespace that Milvus is installed in.
|
#-n namespace: The namespace that Milvus is installed in.
|
||||||
#-i milvus_instance: The name of milvus instance.
|
#-i milvus_instance: The name of milvus instance.
|
||||||
#-p log_path: Log storage path.
|
#-d log_path: Log storage path.
|
||||||
#-e export etcd logs
|
#-e export etcd logs
|
||||||
#-m export minio logs
|
#-m export minio logs
|
||||||
#-u export pulsar logs
|
#-p export pulsar logs
|
||||||
#-k export kafka logs
|
#-k export kafka logs
|
||||||
#-s 24h: export logs since 24h
|
#-s 24h: export logs since 24h
|
||||||
while getopts "n:i:p:s:emuk" opt_name
|
while getopts "n:i:d:s:empko" opt_name
|
||||||
do
|
do
|
||||||
case $opt_name in
|
case $opt_name in
|
||||||
n) namespace=$OPTARG;;
|
n) namespace=$OPTARG;;
|
||||||
i) instance_name=$OPTARG;;
|
i) instance_name=$OPTARG;;
|
||||||
p) log_path=$OPTARG;;
|
d) log_path=$OPTARG;;
|
||||||
e) etcd="true";;
|
e) etcd="true";;
|
||||||
m) minio="true";;
|
m) minio="true";;
|
||||||
u) pulsar="true";;
|
p) pulsar="true";;
|
||||||
k) kafka="true";;
|
k) kafka="true";;
|
||||||
|
o) operator="true";;
|
||||||
s) since=$OPTARG;;
|
s) since=$OPTARG;;
|
||||||
*) echo "Unkonwen parameters";;
|
*) echo "Unkonwen parameters";;
|
||||||
esac
|
esac
|
||||||
@ -48,7 +50,7 @@ then
|
|||||||
since_args="--since=$since"
|
since_args="--since=$since"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "The log files will be stored $(readlink -f $log_path)"
|
echo "The log files will be stored in $(readlink -f $log_path)"
|
||||||
|
|
||||||
|
|
||||||
function export_log(){
|
function export_log(){
|
||||||
@ -80,7 +82,12 @@ fi
|
|||||||
# export etcd component log
|
# export etcd component log
|
||||||
if $etcd;
|
if $etcd;
|
||||||
then
|
then
|
||||||
etcd_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/name=etcd --output=jsonpath={.items..metadata.name})
|
if $operator
|
||||||
|
then
|
||||||
|
etcd_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name-etcd,app.kubernetes.io/name=etcd --output=jsonpath={.items..metadata.name})
|
||||||
|
else
|
||||||
|
etcd_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/name=etcd --output=jsonpath={.items..metadata.name})
|
||||||
|
fi
|
||||||
if [ ${#etcd_pods} == 0 ];
|
if [ ${#etcd_pods} == 0 ];
|
||||||
then
|
then
|
||||||
echo "There is no etcd component for Milvus instance $instance_name in the namespace $namespace"
|
echo "There is no etcd component for Milvus instance $instance_name in the namespace $namespace"
|
||||||
@ -92,7 +99,12 @@ fi
|
|||||||
# export minio component log
|
# export minio component log
|
||||||
if $minio;
|
if $minio;
|
||||||
then
|
then
|
||||||
minio_pods=$(kubectl get pod -n $namespace -l release=$instance_name,app=minio --output=jsonpath={.items..metadata.name})
|
if $operator
|
||||||
|
then
|
||||||
|
minio_pods=$(kubectl get pod -n $namespace -l release=${instance_name}-minio,app=minio --output=jsonpath={.items..metadata.name})
|
||||||
|
else
|
||||||
|
minio_pods=$(kubectl get pod -n $namespace -l release=$instance_name,app=minio --output=jsonpath={.items..metadata.name})
|
||||||
|
fi
|
||||||
if [ ${#minio_pods} == 0 ];
|
if [ ${#minio_pods} == 0 ];
|
||||||
then
|
then
|
||||||
echo "There is no minio component for Milvus instance $instance_name in the namespace $namespace"
|
echo "There is no minio component for Milvus instance $instance_name in the namespace $namespace"
|
||||||
@ -104,7 +116,18 @@ fi
|
|||||||
# export pulsar component log
|
# export pulsar component log
|
||||||
if $pulsar;
|
if $pulsar;
|
||||||
then
|
then
|
||||||
pulsar_pods=$(kubectl get pod -n $namespace -l cluster=$instance_name-pulsar,app=pulsar --output=jsonpath={.items..metadata.name})
|
if $operator
|
||||||
|
then
|
||||||
|
pulsar_pods=$(kubectl get pod -n $namespace -l cluster=${instance_name}-pulsar,app=pulsar --output=jsonpath={.items..metadata.name})
|
||||||
|
else
|
||||||
|
if [[ $instance_name =~ "pulsar" ]]
|
||||||
|
then
|
||||||
|
pulsar_pods=$(kubectl get pod -n $namespace -l cluster=$instance_name,app=pulsar --output=jsonpath={.items..metadata.name})
|
||||||
|
else
|
||||||
|
pulsar_pods=$(kubectl get pod -n $namespace -l cluster=${instance_name}-pulsar,app=pulsar --output=jsonpath={.items..metadata.name})
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${#pulsar_pods} == 0 ];
|
if [ ${#pulsar_pods} == 0 ];
|
||||||
then
|
then
|
||||||
echo "There is no pulsar component for Milvus instance $instance_name in the namespace $namespace"
|
echo "There is no pulsar component for Milvus instance $instance_name in the namespace $namespace"
|
||||||
@ -116,7 +139,13 @@ fi
|
|||||||
# export kafka component log
|
# export kafka component log
|
||||||
if $kafka;
|
if $kafka;
|
||||||
then
|
then
|
||||||
kafka_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/component=kafka --output=jsonpath={.items..metadata.name})
|
if $operator
|
||||||
|
then
|
||||||
|
kafka_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=${instance_name}-kafka,app.kubernetes.io/component=kafka --output=jsonpath={.items..metadata.name})
|
||||||
|
else
|
||||||
|
kafka_pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=${instance_name},app.kubernetes.io/component=kafka --output=jsonpath={.items..metadata.name})
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${#kafka_pods} == 0 ];
|
if [ ${#kafka_pods} == 0 ];
|
||||||
then
|
then
|
||||||
echo "There is no kafka component for Milvus instance $instance_name in the namespace $namespace"
|
echo "There is no kafka component for Milvus instance $instance_name in the namespace $namespace"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user