2021-11-16 21:30:23 +08:00
#!/bin/bash
2022-01-07 13:14:08 +08:00
# Licensed to the LF AI & Data foundation under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
2022-01-06 13:39:59 +08:00
# with the License. You may obtain a copy of the License at
2021-11-16 21:30:23 +08:00
#
2022-01-07 13:14:08 +08:00
# http://www.apache.org/licenses/LICENSE-2.0
2021-11-16 21:30:23 +08:00
#
2022-01-07 13:14:08 +08:00
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2021-11-16 21:30:23 +08:00
2021-11-18 21:33:55 +08:00
# Exit immediately for non zero status
2021-11-16 21:30:23 +08:00
set -e
2021-11-19 17:53:26 +08:00
# Check unset variables
2021-11-16 21:30:23 +08:00
set -u
2021-11-30 19:23:52 +08:00
# Print commands
2021-11-16 21:30:23 +08:00
set -x
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
SOURCE = " $( readlink " $SOURCE " ) "
[ [ $SOURCE != /* ] ] && SOURCE = " $DIR / $SOURCE " # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
ROOT = " $( cd -P " $( dirname " $SOURCE " ) /../.. " && pwd ) "
while ( ( " $# " ) ) ; do
case " $1 " in
--release-name)
RELEASE_NAME = $2
shift 2
; ;
--artifacts-name)
ARTIFACTS_NAME = $2
shift 2
; ;
--log-dir)
LOG_DIR = $2
shift 2
; ;
-h| --help)
{ set +x; } 2>/dev/null
HELP = "
Usage:
$0 [ flags] [ Arguments]
--log-dir Log Path
--artifacts-name Artifacts Name
--release-name Milvus helm release name
-h or --help Print help information
Use \" $0 --help\" for more information about a given command.
"
echo -e " ${ HELP } " ; exit 0
; ;
-*)
echo " Error: Unsupported flag $1 " >& 2
exit 1
; ;
*) # preserve positional arguments
PARAMS += ( " $1 " )
shift
; ;
esac
done
2021-12-28 19:00:29 +08:00
LOG_DIR = ${ LOG_DIR :- /ci-logs/ }
RELEASE_NAME = ${ RELEASE_NAME :- milvus -testing }
RELEASE_LOG_DIR = /${ RELEASE_NAME }
if [ [ ! -d ${ RELEASE_LOG_DIR } ] ] ; then
mkdir -p ${ RELEASE_LOG_DIR }
fi
2022-01-04 19:17:34 +08:00
# Try to found logs file from mount disk /volume1/ci-logs
2023-09-19 14:35:22 +08:00
# log_files=$(find ${LOG_DIR} -type f -name "*${RELEASE_NAME}*" )
2023-10-10 16:17:34 +08:00
log_files = $( ls ${ LOG_DIR } | grep ${ RELEASE_NAME } || echo nonexistent)
2023-10-09 15:45:32 +08:00
2023-10-10 16:17:34 +08:00
if [ " ${ log_files } " = = "nonexistent" ] ; then
2023-08-14 14:53:36 +08:00
echo "No log files find"
else
for log_file in ${ log_files }
do
file_name = $( basename ${ log_file } )
2023-09-19 14:35:22 +08:00
mv ${ LOG_DIR } /${ log_file } ${ RELEASE_LOG_DIR } /` echo ${ file_name } | sed 's/ci.var.log.containers.//g' `
2023-08-14 14:53:36 +08:00
done
tar -zcvf ${ ARTIFACTS_NAME :- artifacts } .tar.gz ${ RELEASE_LOG_DIR } /*
rm -rf ${ RELEASE_LOG_DIR }
fi
2021-12-28 19:00:29 +08:00
2023-09-19 14:35:22 +08:00
# remain_log_files=$(find ${LOG_DIR} -type f -name "*${RELEASE_NAME}*")
2023-10-09 15:45:32 +08:00
# ls ${LOG_DIR} | grep ${RELEASE_NAME}
2023-09-19 14:35:22 +08:00
2023-10-10 16:17:34 +08:00
remain_log_files = $( ls ${ LOG_DIR } | grep ${ RELEASE_NAME } || echo nonexistent)
2021-11-24 16:37:16 +08:00
2023-10-10 16:17:34 +08:00
if [ " ${ remain_log_files } " = = "nonexistent" ] ; then
2021-11-24 16:37:16 +08:00
echo "No remain log files"
else
echo "Still have log files & Remove again"
2023-09-19 14:35:22 +08:00
for log_file in ${ remain_log_files }
do
rm -rf ${ LOG_DIR } /${ log_file }
done
2021-11-24 16:37:16 +08:00
echo "Check if any remain log files after using rm to delete again "
2023-10-10 16:17:34 +08:00
ls ${ LOG_DIR } | grep ${ RELEASE_NAME } || echo nonexistent
2021-11-24 16:37:16 +08:00
fi