[skip e2e] Export logs for etcd, minio and pulsar component (#17404)

Signed-off-by: Bennu-Li <yunmei.li@zilliz.com>
This commit is contained in:
Bennu
2022-06-29 15:06:18 +08:00
committed by GitHub
parent a001412e12
commit 65abd5f2ca
2 changed files with 108 additions and 28 deletions
+20
View File
@@ -15,6 +15,14 @@ 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 |
| e | Export etcd logs | false |
| m | Export Minio logs | false |
| u | Export pulsar logs | false |
| k | Export Kafka logs | 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.
## Usage
@@ -34,3 +42,15 @@ For better tracking and debugging Milvus, the script `export-milvus-log.sh` is p
./export-milvus-log.sh -i my-release -n milvus -p ./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
```
4. Export the logs of milvus and Kafka components.
```
./export-milvus-log.sh -i my-release -n milvus -p ./logs -k
```
+88 -28
View File
@@ -4,22 +4,29 @@
namespace='default'
log_path='./milvus-log'
etcd="false"
minio="false"
pulsar="false"
kafka="false"
#-n namespace: The namespace that Milvus is installed in.
#-i milvus_instance: The name of milvus instance.
#-p log_path: Log storage path.
while getopts "n:i:p:" opt_name
#-e export etcd logs
#-m export minio logs
#-u export pulsar logs
#-k export kafka logs
while getopts "n:i:p:emuk" opt_name
do
case $opt_name in
n) namespace=$OPTARG
;;
i) instance_name=$OPTARG
;;
p) log_path=$OPTARG
;;
*) echo "Unkonwen parameters"
;;
n) namespace=$OPTARG;;
i) instance_name=$OPTARG;;
p) log_path=$OPTARG;;
e) etcd="true";;
m) minio="true";;
u) pulsar="true";;
k) kafka="true";;
*) echo "Unkonwen parameters";;
esac
done
@@ -29,14 +36,6 @@ then
exit 1
fi
pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/name=milvus --output=jsonpath={.items..metadata.name})
if [ ${#pods} == 0 ];
then
echo "There is no Milvus instance $instance_name in the namespace $namespace"
exit 1
fi
if [ ! -d $log_path ];
then
mkdir -p $log_path
@@ -44,19 +43,80 @@ fi
echo "The log files will be stored $(readlink -f $log_path)"
for pod in $pods;
do
# Check if the pod has been restarted
if [ $(kubectl get pod $pod -n $namespace --output=jsonpath={.status.containerStatuses[0].restartCount}) == 0 ];
function export_log(){
# export pod logs
for pod in $1;
do
# Check if the pod has been restarted
if [ $(kubectl get pod $pod -n $namespace --output=jsonpath={.status.containerStatuses[0].restartCount}) == 0 ];
then
echo "Export log of $pod"
kubectl logs $pod -n $namespace > $log_path/$pod.log
else
echo "Export log of $pod"
kubectl logs $pod -n $namespace -p > $log_path/$pod-pre.log
kubectl logs $pod -n $namespace > $log_path/$pod.log
fi
done
}
# export milvus component log
pods=$(kubectl get pod -n $namespace -l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/name=milvus --output=jsonpath={.items..metadata.name})
if [ ${#pods} == 0 ];
then
echo "There is no Milvus instance $instance_name in the namespace $namespace"
else
export_log "${pods[*]}"
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 [ ${#etcd_pods} == 0 ];
then
echo "Export log of $pod"
kubectl logs $pod -n $namespace > $log_path/$pod.log
echo "There is no etcd component for Milvus instance $instance_name in the namespace $namespace"
else
echo "Export log of $pod"
kubectl logs $pod -n $namespace -p > $log_path/$pod-pre.log
kubectl logs $pod -n $namespace > $log_path/$pod.log
export_log "${etcd_pods[*]}"
fi
done
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 [ ${#minio_pods} == 0 ];
then
echo "There is no minio component for Milvus instance $instance_name in the namespace $namespace"
else
export_log "${minio_pods[*]}"
fi
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 [ ${#pulsar_pods} == 0 ];
then
echo "There is no pulsar component for Milvus instance $instance_name in the namespace $namespace"
else
export_log "${pulsar_pods[*]}"
fi
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 [ ${#kafka_pods} == 0 ];
then
echo "There is no kafka component for Milvus instance $instance_name in the namespace $namespace"
else
export_log "${kafka_pods[*]}"
fi
fi
tar zcf $log_path.tar.gz $log_path