The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Feature #14294

need cron job to optimize database

Added by Garrett Honeycutt almost 2 years ago. Updated almost 2 years ago.

Status:ClosedStart date:05/03/2012
Priority:NormalDue date:
Assignee:Will Hopper% Done:

0%

Category:installer
Target version:Commercial edition - PE 2.5.2
Keywords:cron, console, dashboard, maintenance Affected URL:
Branch: Affected PE version:2.5.1

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

According to our docs[1] we should run rake RAILS_ENV=production db:raw:optimize monthly via a crontab. If our docs suggest this, we should ship with it.

[1] – http://docs.puppetlabs.com/dashboard/manual/1.2/maintaining.html#optimizing-the-database

History

#1 Updated by Michael Stahnke almost 2 years ago

  • Assignee set to Moses Mendoza

#2 Updated by Will Hopper almost 2 years ago

  • Assignee changed from Moses Mendoza to Will Hopper

#3 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Unreviewed to Merged - Pending Release
  • Target version set to PE 2.5.2

#4 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Merged - Pending Release to In Topic Branch Pending Review

el/sles still pending

#5 Updated by Matthaus Owens almost 2 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

#6 Updated by Garrett Honeycutt almost 2 years ago

Awesome work.

I noticed that STDOUT for the rake command is sent to /dev/null. We should probably be catching STDOUT and STDERR and piping them to some log file, in case there are issues. Also we should check the return code of the rake command to see if it executed successfully or not. If not, we should log the error, probably with logger(1).

#7 Updated by Matthaus Owens almost 2 years ago

I haven’t looked at the source for the task, but cron logs by default to /var/log/cron, so if there are errors, I would expect them to appear there (and then if the user has some monitoring in place, they can be alerted). When the job succeeds, all it seems to print is a list of tables it touched, which I’m not convinced is useful information (especially since those tables are all of the tables in the console database).

#8 Updated by Garrett Honeycutt almost 2 years ago

With regards to the logging, that makes sense to me and seems practical.

We should still address checking that the rake task actually worked.

#9 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Merged - Pending Release to Code Insufficient

Oh, you’re right, the cron logs aren’t very useful. Whopper, look at using logger to drop errors to /var/log/cron.

This is a quick dirty hack that worked, feel free to improve or discard:

#!/opt/puppet/bin/ruby
# Optimize MySQL Database
bin_path="/opt/puppet/bin"
db_path="/opt/puppet/share/puppet-dashboard"
output=%x{#{bin_path}/rake -s -f #{db_path}/Rakefile RAILS_ENV=production db:raw:optimize 2>&1}
unless $?.success?
  %x{logger -i "#{output}"}
end

#10 Updated by Will Hopper almost 2 years ago

  • Status changed from Code Insufficient to In Topic Branch Pending Review

Pull request for error logging at: https://github.com/puppetlabs/pe-deb-puppet-dashboard/pull/17

A note about logger: It can only log to the system log (/var/log/messages). (The -f flag, though promising, simply allows one to log from another log into the system log). So, currently this will drop errors there rather than /var/log/cron. Should some other tool be used to drop them in the latter, or is the system log sufficient?

#11 Updated by Will Hopper almost 2 years ago

Equivalent el5 pull request: https://github.com/puppetlabs/pe-packages/pull/126

#12 Updated by Matthaus Owens almost 2 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

sweet. merged.

#13 Updated by Matthaus Owens almost 2 years ago

  • Status changed from Merged - Pending Release to Closed

Released in PE 2.5.2

Also available in: Atom PDF