New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix syncing logs when shutting down a server #4807
Fix syncing logs when shutting down a server #4807
Conversation
Thanks for the pull request, @Agrendalath! I've created OSPR-2639 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams. Feel free to add as much of the following information to the ticket:
All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here. |
This is great, thank you for your contribution. @edx/devops can you take a look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- I tested this: Run a server, wrote the logs, performed a reboot and then confirmed the logs with were updated in s3.
- I read through the code
-
I checked for accessibility issues -
Includes documentation
@nedbat, are there any updates on this one? |
@nedbat, is there anything new about this PR? |
@Agrendalath I'm not directly involved with this pull request. @mduboseedx and @natabene are shepherding it, but it needs attention from our devops team for review. |
@nedbat, all right, thanks for info! |
@Agrendalath This is waiting on the devops team. I will check with them again. |
@feanil Could you give this a look? Ned would take it into Ironwood if you can review. Thanks. |
@feanil, are there any updates on this? |
@edx/devops Could you give this a look as soon as you can? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the change. Rather than making changes directly to the RSyslog unit file, I think it makes more sense to create a new service that is started before rsyslog and stopped after systlog.
I don't want to make changes to the unit files of services that ship from standard packages if at all possible.
Take a look here for someone who was trying to solve the same problem: https://unix.stackexchange.com/questions/347415/stop-systemd-service-after-another-at-shutdown-and-reboot
@feanil, good point, thanks for catching it!
Just a nit here: after testing it I believe that we should start this service after the I addressed the review and moved syncing logs to a separate systemd service. |
@feanil, are there any updates on this? |
@Agrendalath Sorry, we have not had a chance to look into this yet. |
@Agrendalath Is this time sensitive or has a specific deadline? |
@natabene, this prevents logs from being lost in cases mentioned in the PR's description, so the sooner the better. |
@Agrendalath 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
I've cherry-picked these two commits onto open-release/ironwood.master. |
Great, thank you @nedbat! |
This fixes syncing logs when rebooting, powering off or halting the instance.
Ubuntu adopted systemd in 15.04 version. Currently there is an init script (running on supervisor's exit) which does not work for
xenial
and more recent distributions. Therefore my proposition is to use systemd service directive for sending logs before shutdown.I decided to run the syncing script on exit of
syslog.service
, because it allows syncing logs before rsyslogd is terminated. Attaching it to supervisor or running it as a separate service didn't produce deterministic results.I've also extracted commands for syncing logs from
playbooks/roles/vhost/templates/etc/init/sync-on-stop.conf.j2
toplaybooks/roles/vhost/templates/sync-logs-on-exit.j2
to avoid code repetition.JIRA ticket: OSPR-2639
Merge deadline: ASAP - it would need to go into Hawthorn
Testing instructions (example for S3, but can be easily adapted for other storages):
ACTIONS = {
REBOOT
,POWER OFF
,HALT
}For each ACTION in $ACTIONS:
echo TEST | sudo tee --append /edx/var/log/tracking/tracking.log
.s3cmd --access_key $AWS_S3_LOGS_ACCESS_KEY_ID --secret_key $AWS_S3_LOGS_SECRET_KEY ls s3://$COMMON_OBJECT_STORE_LOG_SYNC_BUCKET/$COMMON_OBJECT_STORE_LOG_SYNC_PREFIX$(ec2metadata --security-groups | head -1)/$(ec2metadata --instance-id)-$(ec2metadata --local-ipv4)/
.s3cmd --access_key $AWS_S3_LOGS_ACCESS_KEY_ID --secret_key $AWS_S3_LOGS_SECRET_KEY get s3://$COMMON_OBJECT_STORE_LOG_SYNC_BUCKET/$COMMON_OBJECT_STORE_LOG_SYNC_PREFIX$(ec2metadata --security-groups | head -1)/$(ec2metadata --instance-id)-$(ec2metadata --local-ipv4)/$FILE_NAME
.zgrep TEST $DOWNLOADED_FILE
.Reviewers
Make sure that the following steps are done before merging: