[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>
pull/21059/head
Bennu 2022-12-08 09:47:32 +08:00 committed by GitHub
parent 43dce09020
commit ab801a1d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 18 deletions

View File

@ -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 |
| 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 |
| m | Export Minio logs | false |
| u | Export pulsar logs | false |
| p | Export pulsar 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 |
|o |If milvus installed by milvus-operator |false |
> 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
1. Milvus instance name is required to be specified
If Milvus installed by helm, export logs by followings:
```shell
./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.
> 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.
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
./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.
```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.
```
./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.

View File

@ -9,24 +9,26 @@ minio="false"
pulsar="false"
kafka="false"
since_args=""
operator="false"
#-n namespace: The namespace that Milvus is installed in.
#-i milvus_instance: The name of milvus instance.
#-p log_path: Log storage path.
#-d log_path: Log storage path.
#-e export etcd logs
#-m export minio logs
#-u export pulsar logs
#-p export pulsar logs
#-k export kafka logs
#-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
case $opt_name in
n) namespace=$OPTARG;;
i) instance_name=$OPTARG;;
p) log_path=$OPTARG;;
d) log_path=$OPTARG;;
e) etcd="true";;
m) minio="true";;
u) pulsar="true";;
p) pulsar="true";;
k) kafka="true";;
o) operator="true";;
s) since=$OPTARG;;
*) echo "Unkonwen parameters";;
esac
@ -48,7 +50,7 @@ then
since_args="--since=$since"
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(){
@ -80,7 +82,12 @@ fi
# export etcd component log
if $etcd;
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 ];
then
echo "There is no etcd component for Milvus instance $instance_name in the namespace $namespace"
@ -92,7 +99,12 @@ fi
# export minio component log
if $minio;
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 ];
then
echo "There is no minio component for Milvus instance $instance_name in the namespace $namespace"
@ -104,7 +116,18 @@ fi
# export pulsar component log
if $pulsar;
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 ];
then
echo "There is no pulsar component for Milvus instance $instance_name in the namespace $namespace"
@ -116,7 +139,13 @@ fi
# export kafka component log
if $kafka;
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 ];
then
echo "There is no kafka component for Milvus instance $instance_name in the namespace $namespace"