Logging audit for guestagent/couchbase

Adjust logging to conform to logging standards.
Cleaned up a few messages that were unclear, and
added some debug messages for recently added
API stubs.

Fixed a pattern of using LOG.error in exception handlers
merely to log the exception (instead of using
LOG.exception)

Change-Id: I4ed452ddc4e0e9a29f6cbcc9d4e04f3a8b183687
Partial-Bug: #1324206
This commit is contained in:
Amrith Kumar 2014-07-17 14:23:49 -04:00
parent 5f98abb9df
commit 0d163bffe1
2 changed files with 41 additions and 35 deletions

View File

@ -73,9 +73,9 @@ class Manager(periodic_task.PeriodicTasks):
device.unmount_device(device_path)
device.format()
device.mount(mount_point)
LOG.debug('Mounted the volume.')
LOG.debug('Mounted the volume (%s).' % device_path)
self.app.start_db_with_conf_changes(config_contents)
LOG.info(_('Securing couchbase now.'))
LOG.debug('Securing couchbase now.')
if root_password:
self.app.enable_root(root_password)
self.app.initial_setup()
@ -85,7 +85,7 @@ class Manager(periodic_task.PeriodicTasks):
context,
mount_point)
self.app.complete_install_or_restart()
LOG.info(_('"prepare" couchbase call has finished.'))
LOG.info(_('Completed setup of Couchbase database instance.'))
def restart(self, context):
"""
@ -190,38 +190,46 @@ class Manager(periodic_task.PeriodicTasks):
def mount_volume(self, context, device_path=None, mount_point=None):
device = volume.VolumeDevice(device_path)
device.mount(mount_point, write_to_fstab=False)
LOG.debug("Mounted the volume.")
LOG.debug("Mounted the device %s at the mount_point %s." %
(device_path, mount_point))
def unmount_volume(self, context, device_path=None, mount_point=None):
device = volume.VolumeDevice(device_path)
device.unmount(mount_point)
LOG.debug("Unmounted the volume.")
LOG.debug("Unmounted the device %s from the mount point %s." %
(device_path, mount_point))
def resize_fs(self, context, device_path=None, mount_point=None):
device = volume.VolumeDevice(device_path)
device.resize_fs(mount_point)
LOG.debug("Resized the filesystem.")
LOG.debug("Resized the filesystem at %s." % mount_point)
def update_overrides(self, context, overrides, remove=False):
LOG.debug("Updating overrides.")
raise exception.DatastoreOperationNotSupported(
operation='update_overrides', datastore=MANAGER)
def apply_overrides(self, context, overrides):
LOG.debug("Applying overrides.")
raise exception.DatastoreOperationNotSupported(
operation='apply_overrides', datastore=MANAGER)
def get_replication_snapshot(self, master_config):
LOG.debug("Getting replication snapshot.")
raise exception.DatastoreOperationNotSupported(
operation='get_replication_snapshot', datastore=MANAGER)
def attach_replication_slave(self, snapshot, slave_config):
LOG.debug("Attaching replication slave.")
raise exception.DatastoreOperationNotSupported(
operation='attach_replication_slave', datastore=MANAGER)
def detach_replication_slave(self):
LOG.debug("Detaching replication slave.")
raise exception.DatastoreOperationNotSupported(
operation='detach_replication_slave', datastore=MANAGER)
def demote_replication_master(self):
LOG.debug("Demoting replication slave.")
raise exception.DatastoreOperationNotSupported(
operation='demote_replication_master', datastore=MANAGER)

View File

@ -55,16 +55,16 @@ class CouchbaseApp(object):
"""
Install couchbase if needed, do nothing if it is already installed.
"""
LOG.info(_('Preparing Guest as Couchbase Server'))
LOG.info(_('Preparing Guest as Couchbase Server.'))
if not packager.pkg_is_installed(packages):
LOG.info(_('Installing Couchbase'))
LOG.debug('Installing Couchbase.')
self._install_couchbase(packages)
def initial_setup(self):
self.ip_address = operating_system.get_ip_address()
mount_point = CONF.couchbase.mount_point
try:
LOG.info(_('Couchbase Server change data dir path'))
LOG.info(_('Couchbase Server change data dir path.'))
operating_system.update_owner('couchbase',
'couchbase',
mount_point)
@ -76,7 +76,7 @@ class CouchbaseApp(object):
'PWD': pwd}), shell=True)
utils.execute_with_timeout(
system.cmd_rm_old_data_dir, shell=True)
LOG.info(_('Couchbase Server initialize cluster'))
LOG.debug('Couchbase Server initialize cluster.')
utils.execute_with_timeout(
(system.cmd_cluster_init
% {'IP': self.ip_address, 'PWD': pwd}),
@ -84,9 +84,9 @@ class CouchbaseApp(object):
utils.execute_with_timeout(system.cmd_set_swappiness, shell=True)
utils.execute_with_timeout(system.cmd_update_sysctl_conf,
shell=True)
LOG.info(_('Couchbase Server initial setup finished'))
except exception.ProcessExecutionError as e:
LOG.error(_('Process execution error %s') % e)
LOG.info(_('Couchbase Server initial setup finished.'))
except exception.ProcessExecutionError:
LOG.exception(_('Error performing initial Couchbase setup.'))
raise RuntimeError("Couchbase Server initial setup failed")
def complete_install_or_restart(self):
@ -99,9 +99,8 @@ class CouchbaseApp(object):
"""
Install the Couchbase Server.
"""
LOG.debug('Installing Couchbase Server')
msg = "Creating %s" % system.COUCHBASE_CONF_DIR
LOG.debug(msg)
LOG.debug('Installing Couchbase Server. Creating %s' %
system.COUCHBASE_CONF_DIR)
utils.execute_with_timeout('mkdir',
'-p',
system.COUCHBASE_CONF_DIR,
@ -110,7 +109,7 @@ class CouchbaseApp(object):
pkg_opts = {}
packager.pkg_install(packages, pkg_opts, system.TIME_OUT)
self.start_db()
LOG.debug('Finished installing Couchbase Server')
LOG.debug('Finished installing Couchbase Server.')
def _enable_db_on_boot(self):
"""
@ -127,7 +126,7 @@ class CouchbaseApp(object):
"Command to enable Couchbase Server on boot not found."))
def _disable_db_on_boot(self):
LOG.info(_("Disabling Couchbase Server on boot"))
LOG.debug("Disabling Couchbase Server on boot.")
try:
couchbase_service = operating_system.service_discovery(
system.SERVICE_CANDIDATES)
@ -141,7 +140,7 @@ class CouchbaseApp(object):
"""
Stops Couchbase Server on the trove instance.
"""
LOG.info(_('Stopping Couchbase Server...'))
LOG.debug('Stopping Couchbase Server.')
if do_not_start_on_reboot:
self._disable_db_on_boot()
@ -151,17 +150,17 @@ class CouchbaseApp(object):
utils.execute_with_timeout(
couchbase_service['cmd_stop'], shell=True)
except KeyError:
raise RuntimeError("Command to stop Couchbase Server not found")
raise RuntimeError("Command to stop Couchbase Server not found.")
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.SHUTDOWN,
self.state_change_wait_time, update_db):
LOG.error(_('Could not stop Couchbase Server!'))
LOG.error(_('Could not stop Couchbase Server.'))
self.status.end_install_or_restart()
raise RuntimeError(_("Could not stop Couchbase Server"))
raise RuntimeError(_("Could not stop Couchbase Server."))
def restart(self):
LOG.info(_("Restarting Couchbase Server"))
LOG.info(_("Restarting Couchbase Server."))
try:
self.status.begin_restart()
self.stop_db()
@ -173,7 +172,7 @@ class CouchbaseApp(object):
"""
Start the Couchbase Server.
"""
LOG.info(_("Starting Couchbase Server..."))
LOG.info(_("Starting Couchbase Server."))
self._enable_db_on_boot()
try:
@ -189,12 +188,11 @@ class CouchbaseApp(object):
if not self.status.wait_for_real_status_to_change_to(
rd_instance.ServiceStatuses.RUNNING,
self.state_change_wait_time, update_db):
LOG.error(_("Start up of Couchbase Server failed!"))
LOG.error(_("Start up of Couchbase Server failed."))
try:
utils.execute_with_timeout(system.cmd_kill)
except exception.ProcessExecutionError as p:
LOG.error('Error killing stalled Couchbase start command.')
LOG.error(p)
except exception.ProcessExecutionError:
LOG.exception(_('Error killing Couchbase start command.'))
self.status.end_install_or_restart()
raise RuntimeError("Could not start Couchbase Server")
@ -202,25 +200,25 @@ class CouchbaseApp(object):
return CouchbaseRootAccess.enable_root(root_password)
def start_db_with_conf_changes(self, config_contents):
LOG.info(_("Starting Couchbase with configuration changes"))
LOG.info(_("Configuration contents:\n %s") % config_contents)
LOG.info(_("Starting Couchbase with configuration changes."))
LOG.info(_("Configuration contents:\n %s.") % config_contents)
if self.status.is_running:
LOG.error(_("Cannot start Couchbase with configuration changes. "
"Couchbase state == %s!") % self.status)
"Couchbase state == %s.") % self.status)
raise RuntimeError("Couchbase is not stopped.")
self._write_config(config_contents)
self.start_db(True)
def reset_configuration(self, configuration):
config_contents = configuration['config_contents']
LOG.info(_("Resetting configuration"))
LOG.debug("Resetting configuration.")
self._write_config(config_contents)
def _write_config(self, config_contents):
"""
Update contents of Couchbase configuration file
"""
LOG.info(_("Doing nothing."))
return
class CouchbaseAppStatus(service.BaseDbStatus):
@ -240,8 +238,8 @@ class CouchbaseAppStatus(service.BaseDbStatus):
return rd_instance.ServiceStatuses.RUNNING
else:
return rd_instance.ServiceStatuses.SHUTDOWN
except exception.ProcessExecutionError as e:
LOG.error(_("Process execution %s ") % e)
except exception.ProcessExecutionError:
LOG.exception(_("Error getting Couchbase status."))
return rd_instance.ServiceStatuses.SHUTDOWN