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,
|
def prepare(self, context, packages, databases, memory_mb, users,
|
||||||
device_path=None, mount_point=None, backup_info=None,
|
device_path=None, mount_point=None, backup_info=None,
|
||||||
config_contents=None, root_password=None, overrides=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()
|
self.appStatus.begin_install()
|
||||||
LOG.info("Installing cassandra")
|
LOG.debug("Installing cassandra.")
|
||||||
self.app.install_if_needed(packages)
|
self.app.install_if_needed(packages)
|
||||||
self.app.init_storage_structure(mount_point)
|
self.app.init_storage_structure(mount_point)
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||||||
self.app.start_db()
|
self.app.start_db()
|
||||||
|
|
||||||
self.appStatus.end_install_or_restart()
|
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):
|
def change_passwords(self, context, users):
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
@ -167,38 +167,46 @@ class Manager(periodic_task.PeriodicTasks):
|
|||||||
def mount_volume(self, context, device_path=None, mount_point=None):
|
def mount_volume(self, context, device_path=None, mount_point=None):
|
||||||
device = volume.VolumeDevice(device_path)
|
device = volume.VolumeDevice(device_path)
|
||||||
device.mount(mount_point, write_to_fstab=False)
|
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):
|
def unmount_volume(self, context, device_path=None, mount_point=None):
|
||||||
device = volume.VolumeDevice(device_path)
|
device = volume.VolumeDevice(device_path)
|
||||||
device.unmount(mount_point)
|
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):
|
def resize_fs(self, context, device_path=None, mount_point=None):
|
||||||
device = volume.VolumeDevice(device_path)
|
device = volume.VolumeDevice(device_path)
|
||||||
device.resize_fs(mount_point)
|
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):
|
def update_overrides(self, context, overrides, remove=False):
|
||||||
|
LOG.debug("Updating overrides.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='update_overrides', datastore=MANAGER)
|
operation='update_overrides', datastore=MANAGER)
|
||||||
|
|
||||||
def apply_overrides(self, context, overrides):
|
def apply_overrides(self, context, overrides):
|
||||||
|
LOG.debug("Applying overrides.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='apply_overrides', datastore=MANAGER)
|
operation='apply_overrides', datastore=MANAGER)
|
||||||
|
|
||||||
def get_replication_snapshot(self, master_config):
|
def get_replication_snapshot(self, master_config):
|
||||||
|
LOG.debug("Getting replication snapshot.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='get_replication_snapshot', datastore=MANAGER)
|
operation='get_replication_snapshot', datastore=MANAGER)
|
||||||
|
|
||||||
def attach_replication_slave(self, snapshot, slave_config):
|
def attach_replication_slave(self, snapshot, slave_config):
|
||||||
|
LOG.debug("Attaching replication slave.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='attach_replication_slave', datastore=MANAGER)
|
operation='attach_replication_slave', datastore=MANAGER)
|
||||||
|
|
||||||
def detach_replication_slave(self):
|
def detach_replication_slave(self):
|
||||||
|
LOG.debug("Detaching replication slave.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='detach_replication_slave', datastore=MANAGER)
|
operation='detach_replication_slave', datastore=MANAGER)
|
||||||
|
|
||||||
def demote_replication_master(self):
|
def demote_replication_master(self):
|
||||||
|
LOG.debug("Demoting replication master.")
|
||||||
raise exception.DatastoreOperationNotSupported(
|
raise exception.DatastoreOperationNotSupported(
|
||||||
operation='demote_replication_master', datastore=MANAGER)
|
operation='demote_replication_master', datastore=MANAGER)
|
||||||
|
@ -42,10 +42,10 @@ class CassandraApp(object):
|
|||||||
|
|
||||||
def install_if_needed(self, packages):
|
def install_if_needed(self, packages):
|
||||||
"""Prepare the guest machine with a cassandra server installation."""
|
"""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):
|
if not packager.pkg_is_installed(packages):
|
||||||
self._install_db(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):
|
def complete_install_or_restart(self):
|
||||||
self.status.end_install_or_restart()
|
self.status.end_install_or_restart()
|
||||||
@ -62,9 +62,8 @@ class CassandraApp(object):
|
|||||||
try:
|
try:
|
||||||
cmd = system.INIT_FS % mount_point
|
cmd = system.INIT_FS % mount_point
|
||||||
utils.execute_with_timeout(cmd, shell=True)
|
utils.execute_with_timeout(cmd, shell=True)
|
||||||
except exception.ProcessExecutionError as e:
|
except exception.ProcessExecutionError:
|
||||||
LOG.error(_("Error while initiating storage structure."))
|
LOG.exception(_("Error while initiating storage structure."))
|
||||||
LOG.error(e)
|
|
||||||
|
|
||||||
def start_db(self, update_db=False):
|
def start_db(self, update_db=False):
|
||||||
self._enable_db_on_boot()
|
self._enable_db_on_boot()
|
||||||
@ -72,6 +71,7 @@ class CassandraApp(object):
|
|||||||
utils.execute_with_timeout(system.START_CASSANDRA,
|
utils.execute_with_timeout(system.START_CASSANDRA,
|
||||||
shell=True)
|
shell=True)
|
||||||
except exception.ProcessExecutionError:
|
except exception.ProcessExecutionError:
|
||||||
|
LOG.exception(_("Error starting Cassandra"))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not (self.status.
|
if not (self.status.
|
||||||
@ -82,9 +82,8 @@ class CassandraApp(object):
|
|||||||
try:
|
try:
|
||||||
utils.execute_with_timeout(system.CASSANDRA_KILL,
|
utils.execute_with_timeout(system.CASSANDRA_KILL,
|
||||||
shell=True)
|
shell=True)
|
||||||
except exception.ProcessExecutionError as p:
|
except exception.ProcessExecutionError:
|
||||||
LOG.error(_("Error killing stalled Cassandra start command."))
|
LOG.exception(_("Error killing Cassandra start command."))
|
||||||
LOG.error(p)
|
|
||||||
self.status.end_install_or_restart()
|
self.status.end_install_or_restart()
|
||||||
raise RuntimeError(_("Could not start Cassandra"))
|
raise RuntimeError(_("Could not start Cassandra"))
|
||||||
|
|
||||||
@ -98,14 +97,14 @@ class CassandraApp(object):
|
|||||||
if not (self.status.wait_for_real_status_to_change_to(
|
if not (self.status.wait_for_real_status_to_change_to(
|
||||||
rd_instance.ServiceStatuses.SHUTDOWN,
|
rd_instance.ServiceStatuses.SHUTDOWN,
|
||||||
self.state_change_wait_time, update_db)):
|
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()
|
self.status.end_install_or_restart()
|
||||||
raise RuntimeError(_("Could not stop Cassandra"))
|
raise RuntimeError(_("Could not stop Cassandra."))
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
try:
|
try:
|
||||||
self.status.begin_restart()
|
self.status.begin_restart()
|
||||||
LOG.info(_("Restarting DB"))
|
LOG.info(_("Restarting Cassandra server."))
|
||||||
self.stop_db()
|
self.stop_db()
|
||||||
self.start_db()
|
self.start_db()
|
||||||
finally:
|
finally:
|
||||||
@ -113,27 +112,26 @@ class CassandraApp(object):
|
|||||||
|
|
||||||
def _install_db(self, packages):
|
def _install_db(self, packages):
|
||||||
"""Install cassandra server"""
|
"""Install cassandra server"""
|
||||||
LOG.debug("Installing cassandra server")
|
LOG.debug("Installing cassandra server.")
|
||||||
packager.pkg_install(packages, None, system.INSTALL_TIMEOUT)
|
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):
|
def write_config(self, config_contents):
|
||||||
LOG.info(_('Defining temp config holder at '
|
LOG.debug('Defining temp config holder at %s.' %
|
||||||
'%s') % system.CASSANDRA_TEMP_CONF)
|
system.CASSANDRA_TEMP_CONF)
|
||||||
with open(system.CASSANDRA_TEMP_CONF, 'w+') as conf:
|
with open(system.CASSANDRA_TEMP_CONF, 'w+') as conf:
|
||||||
conf.write(config_contents)
|
conf.write(config_contents)
|
||||||
LOG.info(_('Writing new config'))
|
LOG.info(_('Writing new config.'))
|
||||||
utils.execute_with_timeout("sudo", "mv",
|
utils.execute_with_timeout("sudo", "mv",
|
||||||
system.CASSANDRA_TEMP_CONF,
|
system.CASSANDRA_TEMP_CONF,
|
||||||
system.CASSANDRA_CONF)
|
system.CASSANDRA_CONF)
|
||||||
LOG.info(_('Overriding old config'))
|
|
||||||
|
|
||||||
def read_conf(self):
|
def read_conf(self):
|
||||||
"""Returns cassandra.yaml in dict structure."""
|
"""Returns cassandra.yaml in dict structure."""
|
||||||
|
|
||||||
LOG.info(_("Opening cassandra.yaml"))
|
LOG.debug("Opening cassandra.yaml.")
|
||||||
with open(system.CASSANDRA_CONF, 'r') as config:
|
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())
|
yamled = yaml.load(config.read())
|
||||||
return yamled
|
return yamled
|
||||||
|
|
||||||
@ -142,10 +140,10 @@ class CassandraApp(object):
|
|||||||
|
|
||||||
yamled = self.read_conf()
|
yamled = self.read_conf()
|
||||||
yamled.update({key: value})
|
yamled.update({key: value})
|
||||||
LOG.info(_("Updating cassandra.yaml with %(key)s: %(value)s")
|
LOG.debug("Updating cassandra.yaml with %(key)s: %(value)s."
|
||||||
% {'key': key, 'value': value})
|
% {'key': key, 'value': value})
|
||||||
dump = yaml.dump(yamled, default_flow_style=False)
|
dump = yaml.dump(yamled, default_flow_style=False)
|
||||||
LOG.info(_("Dumping YAML to stream"))
|
LOG.debug("Dumping YAML to stream.")
|
||||||
self.write_config(dump)
|
self.write_config(dump)
|
||||||
|
|
||||||
def update_conf_with_group(self, group):
|
def update_conf_with_group(self, group):
|
||||||
@ -159,10 +157,10 @@ class CassandraApp(object):
|
|||||||
update({'seeds': value}))
|
update({'seeds': value}))
|
||||||
else:
|
else:
|
||||||
yamled.update({key: value})
|
yamled.update({key: value})
|
||||||
LOG.info(_("Updating cassandra.yaml with %(key)s: %(value)s")
|
LOG.debug("Updating cassandra.yaml with %(key)s: %(value)s."
|
||||||
% {'key': key, 'value': value})
|
% {'key': key, 'value': value})
|
||||||
dump = yaml.dump(yamled, default_flow_style=False)
|
dump = yaml.dump(yamled, default_flow_style=False)
|
||||||
LOG.info(_("Dumping YAML to stream"))
|
LOG.debug("Dumping YAML to stream")
|
||||||
self.write_config(dump)
|
self.write_config(dump)
|
||||||
|
|
||||||
def make_host_reachable(self):
|
def make_host_reachable(self):
|
||||||
@ -174,20 +172,20 @@ class CassandraApp(object):
|
|||||||
self.update_conf_with_group(updates)
|
self.update_conf_with_group(updates)
|
||||||
|
|
||||||
def start_db_with_conf_changes(self, config_contents):
|
def start_db_with_conf_changes(self, config_contents):
|
||||||
LOG.info(_("Starting cassandra with conf changes..."))
|
LOG.info(_("Starting Cassandra with configuration changes."))
|
||||||
LOG.info(_("inside the guest - cassandra is running %s...")
|
LOG.debug("Inside the guest - Cassandra is running %s."
|
||||||
% self.status.is_running)
|
% self.status.is_running)
|
||||||
if self.status.is_running:
|
if self.status.is_running:
|
||||||
LOG.error(_("Cannot execute start_db_with_conf_changes because "
|
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.")
|
raise RuntimeError("Cassandra not stopped.")
|
||||||
LOG.info(_("Initiating config."))
|
LOG.debug("Initiating config.")
|
||||||
self.write_config(config_contents)
|
self.write_config(config_contents)
|
||||||
self.start_db(True)
|
self.start_db(True)
|
||||||
|
|
||||||
def reset_configuration(self, configuration):
|
def reset_configuration(self, configuration):
|
||||||
config_contents = configuration['config_contents']
|
config_contents = configuration['config_contents']
|
||||||
LOG.info(_("Resetting configuration"))
|
LOG.debug("Resetting configuration")
|
||||||
self.write_config(config_contents)
|
self.write_config(config_contents)
|
||||||
|
|
||||||
|
|
||||||
@ -203,9 +201,6 @@ class CassandraAppStatus(service.BaseDbStatus):
|
|||||||
return rd_instance.ServiceStatuses.RUNNING
|
return rd_instance.ServiceStatuses.RUNNING
|
||||||
else:
|
else:
|
||||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||||
except exception.ProcessExecutionError as e:
|
except (exception.ProcessExecutionError, OSError):
|
||||||
LOG.error(_("Process execution %s") % e)
|
LOG.exception(_("Error getting Cassandra status"))
|
||||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
|
||||||
except OSError as e:
|
|
||||||
LOG.error(_("OS Error %s") % e)
|
|
||||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||||
|
@ -14,9 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from trove.common import cfg
|
from trove.common import cfg
|
||||||
from trove.openstack.common import log as logging
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
CASSANDRA_DATA_DIR = "/var/lib/cassandra/data"
|
CASSANDRA_DATA_DIR = "/var/lib/cassandra/data"
|
||||||
|
Loading…
Reference in New Issue
Block a user