Logging audit for guestagent/cassandra
Adjust logging to conform to logging standards. Cleaned up some messages that were unclear and changed many messages from LOG.info to LOG.debug. Fixed a pattern of exception handlers using LOG.error to log the exception (instead of LOG.exception) Change-Id: I828fbb38b6bf6eb36c349d83475ca46c28779225 Partial-Bug: #1324206
This commit is contained in:
parent
24b1f25204
commit
cf7694f0db
@ -61,9 +61,9 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
def prepare(self, context, packages, databases, memory_mb, users,
|
||||
device_path=None, mount_point=None, backup_info=None,
|
||||
config_contents=None, root_password=None, overrides=None):
|
||||
LOG.info(_("Setting status BUILDING"))
|
||||
LOG.info(_("Setting status of instance to BUILDING."))
|
||||
self.appStatus.begin_install()
|
||||
LOG.info("Installing cassandra")
|
||||
LOG.debug("Installing cassandra.")
|
||||
self.app.install_if_needed(packages)
|
||||
self.app.init_storage_structure(mount_point)
|
||||
|
||||
@ -96,7 +96,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
self.app.start_db()
|
||||
|
||||
self.appStatus.end_install_or_restart()
|
||||
LOG.info(_('"prepare" call has finished.'))
|
||||
LOG.info(_("Completed setup of Cassandra database instance."))
|
||||
|
||||
def change_passwords(self, context, users):
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
@ -167,38 +167,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 master.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='demote_replication_master', datastore=MANAGER)
|
||||
|
@ -42,10 +42,10 @@ class CassandraApp(object):
|
||||
|
||||
def install_if_needed(self, packages):
|
||||
"""Prepare the guest machine with a cassandra server installation."""
|
||||
LOG.info(_("Preparing Guest as Cassandra Server"))
|
||||
LOG.info(_("Preparing Guest as a Cassandra Server"))
|
||||
if not packager.pkg_is_installed(packages):
|
||||
self._install_db(packages)
|
||||
LOG.info(_("Dbaas install_if_needed complete"))
|
||||
LOG.debug("Cassandra install_if_needed complete")
|
||||
|
||||
def complete_install_or_restart(self):
|
||||
self.status.end_install_or_restart()
|
||||
@ -62,9 +62,8 @@ class CassandraApp(object):
|
||||
try:
|
||||
cmd = system.INIT_FS % mount_point
|
||||
utils.execute_with_timeout(cmd, shell=True)
|
||||
except exception.ProcessExecutionError as e:
|
||||
LOG.error(_("Error while initiating storage structure."))
|
||||
LOG.error(e)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.exception(_("Error while initiating storage structure."))
|
||||
|
||||
def start_db(self, update_db=False):
|
||||
self._enable_db_on_boot()
|
||||
@ -72,6 +71,7 @@ class CassandraApp(object):
|
||||
utils.execute_with_timeout(system.START_CASSANDRA,
|
||||
shell=True)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.exception(_("Error starting Cassandra"))
|
||||
pass
|
||||
|
||||
if not (self.status.
|
||||
@ -82,9 +82,8 @@ class CassandraApp(object):
|
||||
try:
|
||||
utils.execute_with_timeout(system.CASSANDRA_KILL,
|
||||
shell=True)
|
||||
except exception.ProcessExecutionError as p:
|
||||
LOG.error(_("Error killing stalled Cassandra start command."))
|
||||
LOG.error(p)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.exception(_("Error killing Cassandra start command."))
|
||||
self.status.end_install_or_restart()
|
||||
raise RuntimeError(_("Could not start Cassandra"))
|
||||
|
||||
@ -98,14 +97,14 @@ class CassandraApp(object):
|
||||
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 Cassandra"))
|
||||
LOG.error(_("Could not stop Cassandra."))
|
||||
self.status.end_install_or_restart()
|
||||
raise RuntimeError(_("Could not stop Cassandra"))
|
||||
raise RuntimeError(_("Could not stop Cassandra."))
|
||||
|
||||
def restart(self):
|
||||
try:
|
||||
self.status.begin_restart()
|
||||
LOG.info(_("Restarting DB"))
|
||||
LOG.info(_("Restarting Cassandra server."))
|
||||
self.stop_db()
|
||||
self.start_db()
|
||||
finally:
|
||||
@ -113,27 +112,26 @@ class CassandraApp(object):
|
||||
|
||||
def _install_db(self, packages):
|
||||
"""Install cassandra server"""
|
||||
LOG.debug("Installing cassandra server")
|
||||
LOG.debug("Installing cassandra server.")
|
||||
packager.pkg_install(packages, None, system.INSTALL_TIMEOUT)
|
||||
LOG.debug("Finished installing cassandra server")
|
||||
LOG.debug("Finished installing Cassandra server")
|
||||
|
||||
def write_config(self, config_contents):
|
||||
LOG.info(_('Defining temp config holder at '
|
||||
'%s') % system.CASSANDRA_TEMP_CONF)
|
||||
LOG.debug('Defining temp config holder at %s.' %
|
||||
system.CASSANDRA_TEMP_CONF)
|
||||
with open(system.CASSANDRA_TEMP_CONF, 'w+') as conf:
|
||||
conf.write(config_contents)
|
||||
LOG.info(_('Writing new config'))
|
||||
LOG.info(_('Writing new config.'))
|
||||
utils.execute_with_timeout("sudo", "mv",
|
||||
system.CASSANDRA_TEMP_CONF,
|
||||
system.CASSANDRA_CONF)
|
||||
LOG.info(_('Overriding old config'))
|
||||
|
||||
def read_conf(self):
|
||||
"""Returns cassandra.yaml in dict structure."""
|
||||
|
||||
LOG.info(_("Opening cassandra.yaml"))
|
||||
LOG.debug("Opening cassandra.yaml.")
|
||||
with open(system.CASSANDRA_CONF, 'r') as config:
|
||||
LOG.info(_("Preparing YAML object from cassandra.yaml"))
|
||||
LOG.debug("Preparing YAML object from cassandra.yaml.")
|
||||
yamled = yaml.load(config.read())
|
||||
return yamled
|
||||
|
||||
@ -142,10 +140,10 @@ class CassandraApp(object):
|
||||
|
||||
yamled = self.read_conf()
|
||||
yamled.update({key: value})
|
||||
LOG.info(_("Updating cassandra.yaml with %(key)s: %(value)s")
|
||||
% {'key': key, 'value': value})
|
||||
LOG.debug("Updating cassandra.yaml with %(key)s: %(value)s."
|
||||
% {'key': key, 'value': value})
|
||||
dump = yaml.dump(yamled, default_flow_style=False)
|
||||
LOG.info(_("Dumping YAML to stream"))
|
||||
LOG.debug("Dumping YAML to stream.")
|
||||
self.write_config(dump)
|
||||
|
||||
def update_conf_with_group(self, group):
|
||||
@ -159,10 +157,10 @@ class CassandraApp(object):
|
||||
update({'seeds': value}))
|
||||
else:
|
||||
yamled.update({key: value})
|
||||
LOG.info(_("Updating cassandra.yaml with %(key)s: %(value)s")
|
||||
% {'key': key, 'value': value})
|
||||
LOG.debug("Updating cassandra.yaml with %(key)s: %(value)s."
|
||||
% {'key': key, 'value': value})
|
||||
dump = yaml.dump(yamled, default_flow_style=False)
|
||||
LOG.info(_("Dumping YAML to stream"))
|
||||
LOG.debug("Dumping YAML to stream")
|
||||
self.write_config(dump)
|
||||
|
||||
def make_host_reachable(self):
|
||||
@ -174,20 +172,20 @@ class CassandraApp(object):
|
||||
self.update_conf_with_group(updates)
|
||||
|
||||
def start_db_with_conf_changes(self, config_contents):
|
||||
LOG.info(_("Starting cassandra with conf changes..."))
|
||||
LOG.info(_("inside the guest - cassandra is running %s...")
|
||||
% self.status.is_running)
|
||||
LOG.info(_("Starting Cassandra with configuration changes."))
|
||||
LOG.debug("Inside the guest - Cassandra is running %s."
|
||||
% self.status.is_running)
|
||||
if self.status.is_running:
|
||||
LOG.error(_("Cannot execute start_db_with_conf_changes because "
|
||||
"cassandra state == %s!") % self.status)
|
||||
"Cassandra state == %s.") % self.status)
|
||||
raise RuntimeError("Cassandra not stopped.")
|
||||
LOG.info(_("Initiating config."))
|
||||
LOG.debug("Initiating config.")
|
||||
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)
|
||||
|
||||
|
||||
@ -203,9 +201,6 @@ class CassandraAppStatus(service.BaseDbStatus):
|
||||
return rd_instance.ServiceStatuses.RUNNING
|
||||
else:
|
||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||
except exception.ProcessExecutionError as e:
|
||||
LOG.error(_("Process execution %s") % e)
|
||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||
except OSError as e:
|
||||
LOG.error(_("OS Error %s") % e)
|
||||
except (exception.ProcessExecutionError, OSError):
|
||||
LOG.exception(_("Error getting Cassandra status"))
|
||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||
|
@ -14,9 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from trove.common import cfg
|
||||
from trove.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
CASSANDRA_DATA_DIR = "/var/lib/cassandra/data"
|
||||
|
Loading…
Reference in New Issue
Block a user