[skip e2e] Update export logs to support time range (#18726)

Signed-off-by: Jenny Li <jing.li@zilliz.com>

Signed-off-by: Jenny Li <jing.li@zilliz.com>
pull/19201/head
Jenny Li 2022-09-14 16:04:30 +08:00 committed by GitHub
parent 25f5ff36b3
commit 16bfa6351a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -21,7 +21,7 @@ For better tracking and debugging Milvus, the script `export-milvus-log.sh` is p
| m | Export Minio logs | false |
| u | 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 |
> 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.
@ -56,3 +56,9 @@ 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 -k
```
5. Export the logs for only latest 24h.
```
./export-milvus-log.sh -i my-release -s 24h
```

View File

@ -8,7 +8,7 @@ etcd="false"
minio="false"
pulsar="false"
kafka="false"
since_args=""
#-n namespace: The namespace that Milvus is installed in.
#-i milvus_instance: The name of milvus instance.
#-p log_path: Log storage path.
@ -16,7 +16,8 @@ kafka="false"
#-m export minio logs
#-u export pulsar logs
#-k export kafka logs
while getopts "n:i:p:emuk" opt_name
#-s 24h: export logs since 24h
while getopts "n:i:p:s:emuk" opt_name
do
case $opt_name in
n) namespace=$OPTARG;;
@ -26,6 +27,7 @@ do
m) minio="true";;
u) pulsar="true";;
k) kafka="true";;
s) since=$OPTARG;;
*) echo "Unkonwen parameters";;
esac
done
@ -41,6 +43,11 @@ then
mkdir -p $log_path
fi
if [ $since ];
then
since_args="--since=$since"
fi
echo "The log files will be stored $(readlink -f $log_path)"
@ -52,11 +59,11 @@ function export_log(){
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
kubectl logs $pod -n $namespace ${since_args}> $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
kubectl logs $pod -n $namespace -p ${since_args}> $log_path/$pod-pre.log
kubectl logs $pod -n $namespace ${since_args}> $log_path/$pod.log
fi
done
}