diff options
author | Mike Pittaro <mikeyp@LaHondaResearch.org> | 2012-02-24 09:56:26 -0800 |
---|---|---|
committer | Mike Pittaro <mikeyp@LaHondaResearch.org> | 2012-02-24 15:10:33 -0800 |
commit | 2fbccc0c693193533284330325f5803c8c6ce52a (patch) | |
tree | fc803aa94449aa53add79f4e17d0eb660f5ab757 /tools | |
parent | 48c08d048bfe8c60cf3cd03c1078e2605bbb0a18 (diff) | |
download | nova-2fbccc0c693193533284330325f5803c8c6ce52a.tar.gz |
Clean stale lockfiles on service startup : fixes bug 785955
Adds cleanup_files_locks() to nova/utils, which cleans up stale locks
left behind after process failures.
Adds a call to clean up locks on service startup for nova-api, nova-cert,
nova-compute, nova-network, nova-objectstore, and nova-scheduler.
Adds tools/clean_file_locks.py, which can be used to manually clean
stale locks.
Change-Id: I752e0b24d3c7fc5f1dc290da355cbd7f430789b8
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/clean_file_locks.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/clean_file_locks.py b/tools/clean_file_locks.py new file mode 100755 index 0000000000..eb21177aa5 --- /dev/null +++ b/tools/clean_file_locks.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +# Copyright 2012 La Honda Research Center, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +"""clean_file_locks.py - Cleans stale interprocess locks + +This rountine can be used to find and delete stale lock files from +nova's interprocess synchroization. It can be used safely while services +are running. + +""" + +import logging +import optparse + +from nova import flags +from nova import utils +from nova import log + + +LOG = log.getLogger('nova.utils') +FLAGS = flags.FLAGS + + +def parse_options(): + """process command line options.""" + + parser = optparse.OptionParser('usage: %prog [options]') + parser.add_option('--verbose', action='store_true', + help='List lock files found and deleted') + + options, args = parser.parse_args() + + return options, args + + +def main(): + """Main loop.""" + options, args = parse_options() + verbose = options.verbose + + if verbose: + LOG.logger.setLevel(logging.DEBUG) + else: + LOG.logger.setLevel(logging.INFO) + LOG.info('Cleaning stale locks from %s' % FLAGS.lock_path) + utils.cleanup_file_locks() + LOG.info('Finished') + +if __name__ == '__main__': + main() |