-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kokoro automation - Log rotation using logrotate (#1008)
* Removing the dependency of log_rotation branch * Minor correction * Removing experimental flag from setup_container * Fixing permission issue * Fixing permission related issue * Half change log-rotation * Half change log-rotation * Refactoring to use the same code by tf/workflow * Fixing issue arosen due to refactoring * Fixing the source env variable issue * Changing for 7 days run period and changing logrotation config
- Loading branch information
1 parent
1901dde
commit 2ad9b90
Showing
4 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
perfmetrics/scripts/continuous_test/ml_tests/pytorch/dino/continuous.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
# This will setup the rotation of log-file present at the $1 | ||
# Please provide the absolute path of log-file. | ||
|
||
log_file=$1 | ||
echo "Creating logrotate configuration..." | ||
cat << EOF | sudo tee ${KOKORO_ARTIFACTS_DIR}/github/gcsfuse/gcsfuse_logrotate.conf | ||
${log_file} { | ||
su root adm | ||
rotate 3 | ||
size 1G | ||
missingok | ||
notifempty | ||
compress | ||
dateext | ||
dateformat -%Y%m%d-%s | ||
copytruncate | ||
} | ||
EOF | ||
|
||
# Set the correct access permission to the config file. | ||
sudo chmod 0644 ${KOKORO_ARTIFACTS_DIR}/github/gcsfuse/gcsfuse_logrotate.conf | ||
sudo chown root ${KOKORO_ARTIFACTS_DIR}/github/gcsfuse/gcsfuse_logrotate.conf | ||
|
||
# Make sure logrotate installed on the system. | ||
if test -x /usr/sbin/logrotate ; then | ||
echo "Logrotate already installed on the system." | ||
else | ||
echo "Installing logrotate on the system..." | ||
sudo apt-get install logrotate | ||
fi | ||
|
||
# Add a shell script which will be run hourly, which eventually executes the | ||
# command to rotate the logs according to config present in /etc/logrotate.hourly.d | ||
cat << EOF | sudo tee /etc/cron.hourly/gcsfuse_logrotate | ||
#!/bin/bash | ||
test -x /usr/sbin/logrotate || exit 0 | ||
/usr/sbin/logrotate ${KOKORO_ARTIFACTS_DIR}/github/gcsfuse/gcsfuse_logrotate.conf --state ${KOKORO_ARTIFACTS_DIR}/github/gcsfuse/gcsfuse_logrotate_status | ||
EOF | ||
|
||
# Make sure, we have hourly logrotate setup inplace correctly. | ||
if [ $? -eq 0 ]; then | ||
echo "Hourly cron setup for logrotate completed successfully" | ||
else | ||
echo "Please install linux package - cron" | ||
exit 1 | ||
fi | ||
|
||
sudo chmod 775 /etc/cron.hourly/gcsfuse_logrotate | ||
|
||
# Restart the cron service | ||
sudo service cron restart |