Logging audit for guestagent/redis
Adjust logging to conform to logging standards. Cleaned up a few messages that were unclear and changed some LOG.info messages to LOG.debug Change-Id: I3570dddf0ba7c576b4cf9cb6affa55335fd23ac7 Partial-Bug: #1324206
This commit is contained in:
parent
99d0e16100
commit
5b0f26aac2
|
@ -43,6 +43,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
Updates the redis trove instance. It is decorated with
|
||||
perodic task so it is automatically called every 3 ticks.
|
||||
"""
|
||||
LOG.debug("Update status called.")
|
||||
RedisAppStatus.get().update()
|
||||
|
||||
def change_passwords(self, context, users):
|
||||
|
@ -50,6 +51,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
Changes the redis instance password,
|
||||
it is currently not not implemented.
|
||||
"""
|
||||
LOG.debug("Change passwords called.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='change_passwords', datastore=MANAGER)
|
||||
|
||||
|
@ -58,6 +60,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
Resets to the default configuration,
|
||||
currently this does nothing.
|
||||
"""
|
||||
LOG.debug("Reset configuration called.")
|
||||
app = RedisApp(RedisAppStatus.get())
|
||||
app.reset_configuration(configuration)
|
||||
|
||||
|
@ -66,6 +69,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
Perform a restore on this instance,
|
||||
currently it is not implemented.
|
||||
"""
|
||||
LOG.debug("Perform restore called.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='_perform_restore', datastore=MANAGER)
|
||||
|
||||
|
@ -90,12 +94,12 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
operating_system.update_owner('redis', 'redis', mount_point)
|
||||
LOG.debug('Mounted the volume.')
|
||||
app.install_if_needed(packages)
|
||||
LOG.info(_('Securing redis now.'))
|
||||
LOG.info(_('Writing redis configuration.'))
|
||||
app.write_config(config_contents)
|
||||
app.restart()
|
||||
LOG.info(_('"prepare" redis call has finished.'))
|
||||
except Exception as e:
|
||||
LOG.error(e)
|
||||
LOG.info(_('Redis instance has been setup and configured.'))
|
||||
except Exception:
|
||||
LOG.exception(_("Error setting up Redis instance."))
|
||||
app.status.set_status(rd_instance.ServiceStatuses.FAILED)
|
||||
raise RuntimeError("prepare call has failed.")
|
||||
|
||||
|
@ -105,6 +109,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
This method is called when the guest agent
|
||||
gets a restart message from the taskmanager.
|
||||
"""
|
||||
LOG.debug("Restart called.")
|
||||
app = RedisApp(RedisAppStatus.get())
|
||||
app.restart()
|
||||
|
||||
|
@ -112,6 +117,7 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
"""
|
||||
Start this redis instance with new conf changes.
|
||||
"""
|
||||
LOG.debug("Start DB with conf changes called.")
|
||||
app = RedisApp(RedisAppStatus.get())
|
||||
app.start_db_with_conf_changes(config_contents)
|
||||
|
||||
|
@ -121,11 +127,13 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
This method is called when the guest agent
|
||||
gets a stop message from the taskmanager.
|
||||
"""
|
||||
LOG.debug("Stop DB called.")
|
||||
app = RedisApp(RedisAppStatus.get())
|
||||
app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)
|
||||
|
||||
def get_filesystem_stats(self, context, fs_path):
|
||||
"""Gets the filesystem stats for the path given."""
|
||||
LOG.debug("Get Filesystem Stats.")
|
||||
mount_point = CONF.get(
|
||||
'mysql' if not MANAGER else MANAGER).mount_point
|
||||
return dbaas.get_filesystem_volume_stats(mount_point)
|
||||
|
@ -135,99 +143,121 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
This will eventually create a backup. Right now
|
||||
it does nothing.
|
||||
"""
|
||||
LOG.debug("Create Backup called.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='create_backup', datastore=MANAGER)
|
||||
|
||||
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 update_attributes(self, context, username, hostname, user_attrs):
|
||||
LOG.debug("Updating attributes.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='update_attributes', datastore=MANAGER)
|
||||
|
||||
def create_database(self, context, databases):
|
||||
LOG.debug("Creating database.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='create_database', datastore=MANAGER)
|
||||
|
||||
def create_user(self, context, users):
|
||||
LOG.debug("Creating user.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='create_user', datastore=MANAGER)
|
||||
|
||||
def delete_database(self, context, database):
|
||||
LOG.debug("Deleting database.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='delete_database', datastore=MANAGER)
|
||||
|
||||
def delete_user(self, context, user):
|
||||
LOG.debug("Deleting user.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='delete_user', datastore=MANAGER)
|
||||
|
||||
def get_user(self, context, username, hostname):
|
||||
LOG.debug("Getting user.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='get_user', datastore=MANAGER)
|
||||
|
||||
def grant_access(self, context, username, hostname, databases):
|
||||
LOG.debug("Granting access.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='grant_access', datastore=MANAGER)
|
||||
|
||||
def revoke_access(self, context, username, hostname, database):
|
||||
LOG.debug("Revoking access.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='revoke_access', datastore=MANAGER)
|
||||
|
||||
def list_access(self, context, username, hostname):
|
||||
LOG.debug("Listing access.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='list_access', datastore=MANAGER)
|
||||
|
||||
def list_databases(self, context, limit=None, marker=None,
|
||||
include_marker=False):
|
||||
LOG.debug("Listing databases.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='list_databases', datastore=MANAGER)
|
||||
|
||||
def list_users(self, context, limit=None, marker=None,
|
||||
include_marker=False):
|
||||
LOG.debug("Listing users.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='list_users', datastore=MANAGER)
|
||||
|
||||
def enable_root(self, context):
|
||||
LOG.debug("Enabling root.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='enable_root', datastore=MANAGER)
|
||||
|
||||
def is_root_enabled(self, context):
|
||||
LOG.debug("Checking if root is enabled.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='is_root_enabled', datastore=MANAGER)
|
||||
|
||||
def get_replication_snapshot(self, context, snapshot_info,
|
||||
replica_source_config=None):
|
||||
LOG.debug("Getting replication snapshot.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='get_replication_snapshot', datastore=MANAGER)
|
||||
|
||||
def attach_replication_slave(self, context, snapshot, slave_config):
|
||||
LOG.debug("Attaching replica.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='attach_replication_slave', datastore=MANAGER)
|
||||
|
||||
def detach_replica(self, context):
|
||||
LOG.debug("Detaching replica.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='detach_replica', datastore=MANAGER)
|
||||
|
||||
def demote_replication_master(self, context):
|
||||
LOG.debug("Demoting replica source.")
|
||||
raise exception.DatastoreOperationNotSupported(
|
||||
operation='demote_replication_master', datastore=MANAGER)
|
||||
|
|
|
@ -41,6 +41,7 @@ def _load_redis_options():
|
|||
So: 'foo bar baz' becomes {'foo' : 'bar baz'}
|
||||
"""
|
||||
options = {}
|
||||
LOG.debug("Loading Redis options.")
|
||||
with open(system.REDIS_CONFIG, 'r') as fd:
|
||||
for opt in fd.readlines():
|
||||
opt = opt.rstrip().split(' ')
|
||||
|
@ -83,7 +84,7 @@ class RedisAppStatus(service.BaseDbStatus):
|
|||
err = ""
|
||||
try:
|
||||
if 'requirepass' in options:
|
||||
LOG.info(_('Password is set running ping with password'))
|
||||
LOG.debug('Password is set, running ping with password.')
|
||||
out, err = utils.execute_with_timeout(
|
||||
system.REDIS_CLI,
|
||||
'-a',
|
||||
|
@ -92,33 +93,32 @@ class RedisAppStatus(service.BaseDbStatus):
|
|||
run_as_root=True,
|
||||
root_helper='sudo')
|
||||
else:
|
||||
LOG.info(_('Password not set running ping without password'))
|
||||
LOG.debug('Password not set, running ping without password.')
|
||||
out, err = utils.execute_with_timeout(
|
||||
system.REDIS_CLI,
|
||||
'PING',
|
||||
run_as_root=True,
|
||||
root_helper='sudo')
|
||||
LOG.info(_('Redis is RUNNING.'))
|
||||
LOG.info(_('Redis Service Status is RUNNING.'))
|
||||
return rd_instance.ServiceStatuses.RUNNING
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.error(_('Process execution error on redis-cli'))
|
||||
LOG.exception(_('Process execution error on redis-cli.'))
|
||||
if 'PONG' not in out:
|
||||
try:
|
||||
out, err = utils.execute_with_timeout('/bin/ps', '-C',
|
||||
'redis-server', 'h')
|
||||
pid = out.split()[0]
|
||||
msg = _('Redis pid: %s') % (pid)
|
||||
LOG.info(msg)
|
||||
LOG.info(_('Service Status is BLOCKED.'))
|
||||
LOG.debug('Redis pid: %s.' % (pid))
|
||||
LOG.info(_('Redis Service Status is BLOCKED.'))
|
||||
return rd_instance.ServiceStatuses.BLOCKED
|
||||
except exception.ProcessExecutionError:
|
||||
pid_file = options.get('pidfile',
|
||||
'/var/run/redis/redis-server.pid')
|
||||
if os.path.exists(pid_file):
|
||||
LOG.info(_('Service Status is CRASHED.'))
|
||||
LOG.info(_('Redis Service Status is CRASHED.'))
|
||||
return rd_instance.ServiceStatuses.CRASHED
|
||||
else:
|
||||
LOG.info(_('Service Status is SHUTDOWN.'))
|
||||
LOG.info(_('Redis Service Status is SHUTDOWN.'))
|
||||
return rd_instance.ServiceStatuses.SHUTDOWN
|
||||
|
||||
|
||||
|
@ -142,24 +142,25 @@ class RedisApp(object):
|
|||
"""
|
||||
Install redis if needed do nothing if it is already installed.
|
||||
"""
|
||||
LOG.info(_('Preparing Guest as Redis Server'))
|
||||
LOG.info(_('Preparing Guest as Redis Server.'))
|
||||
if not packager.pkg_is_installed(packages):
|
||||
LOG.info(_('Installing Redis'))
|
||||
LOG.info(_('Installing Redis.'))
|
||||
self._install_redis(packages)
|
||||
LOG.info(_('Dbaas install_if_needed complete'))
|
||||
LOG.info(_('Redis installed completely.'))
|
||||
|
||||
def complete_install_or_restart(self):
|
||||
"""
|
||||
finalize status updates for install or restart.
|
||||
"""
|
||||
LOG.debug("Complete install or restart called.")
|
||||
self.status.end_install_or_restart()
|
||||
|
||||
def _install_redis(self, packages):
|
||||
"""
|
||||
Install the redis server.
|
||||
"""
|
||||
LOG.debug('Installing redis server')
|
||||
msg = "Creating %s" % system.REDIS_CONF_DIR
|
||||
LOG.debug('Installing redis server.')
|
||||
msg = "Creating %s." % system.REDIS_CONF_DIR
|
||||
LOG.debug(msg)
|
||||
utils.execute_with_timeout('mkdir',
|
||||
'-p',
|
||||
|
@ -169,7 +170,7 @@ class RedisApp(object):
|
|||
pkg_opts = {}
|
||||
packager.pkg_install(packages, pkg_opts, TIME_OUT)
|
||||
self.start_redis()
|
||||
LOG.debug('Finished installing redis server')
|
||||
LOG.debug('Finished installing redis server.')
|
||||
|
||||
def _enable_redis_on_boot(self):
|
||||
"""
|
||||
|
@ -203,7 +204,7 @@ class RedisApp(object):
|
|||
"""
|
||||
Stops the redis application on the trove instance.
|
||||
"""
|
||||
LOG.info(_('Stopping redis...'))
|
||||
LOG.info(_('Stopping redis.'))
|
||||
if do_not_start_on_reboot:
|
||||
self._disable_redis_on_boot()
|
||||
cmd = 'sudo %s' % (system.REDIS_CMD_STOP)
|
||||
|
@ -212,13 +213,14 @@ class RedisApp(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 Redis!'))
|
||||
LOG.error(_('Could not stop Redis.'))
|
||||
self.status.end_install_or_restart()
|
||||
|
||||
def restart(self):
|
||||
"""
|
||||
Restarts the redis daemon.
|
||||
"""
|
||||
LOG.debug("Restarting Redis daemon.")
|
||||
try:
|
||||
self.status.begin_restart()
|
||||
self.stop_db()
|
||||
|
@ -230,6 +232,7 @@ class RedisApp(object):
|
|||
"""
|
||||
Write the redis config.
|
||||
"""
|
||||
LOG.debug("Writing Redis config.")
|
||||
with open(TMP_REDIS_CONF, 'w') as fd:
|
||||
fd.write(config_contents)
|
||||
utils.execute_with_timeout('mv',
|
||||
|
@ -239,24 +242,25 @@ class RedisApp(object):
|
|||
root_helper='sudo')
|
||||
|
||||
def start_db_with_conf_changes(self, config_contents):
|
||||
LOG.info(_('Starting redis with conf changes...'))
|
||||
LOG.info(_('Starting redis with conf changes.'))
|
||||
if self.status.is_running:
|
||||
raise RuntimeError('Cannot start_db_with_conf_changes because '
|
||||
'status is %s' % self.status)
|
||||
format = 'Cannot start_db_with_conf_changes because status is %s.'
|
||||
LOG.debug(format, self.status)
|
||||
raise RuntimeError(format % self.status)
|
||||
LOG.info(_("Initiating config."))
|
||||
self.write_config(config_contents)
|
||||
self.start_redis(True)
|
||||
|
||||
def reset_configuration(self, configuration):
|
||||
config_contents = configuration['config_contents']
|
||||
LOG.info(_("Resetting configuration"))
|
||||
LOG.info(_("Resetting configuration."))
|
||||
self.write_config(config_contents)
|
||||
|
||||
def start_redis(self, update_db=False):
|
||||
"""
|
||||
Start the redis daemon.
|
||||
"""
|
||||
LOG.info(_("Starting redis..."))
|
||||
LOG.info(_("Starting redis."))
|
||||
self._enable_redis_on_boot()
|
||||
try:
|
||||
cmd = 'sudo %s' % (system.REDIS_CMD_START)
|
||||
|
@ -267,13 +271,12 @@ class RedisApp(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 redis failed!"))
|
||||
LOG.error(_("Start up of redis failed."))
|
||||
try:
|
||||
utils.execute_with_timeout('pkill', '-9',
|
||||
'redis-server',
|
||||
run_as_root=True,
|
||||
root_helper='sudo')
|
||||
except exception.ProcessExecutionError as p:
|
||||
LOG.error('Error killing stalled redis start command.')
|
||||
LOG.error(p)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.exception(_('Error killing stalled redis start command.'))
|
||||
self.status.end_install_or_restart()
|
||||
|
|
Loading…
Reference in New Issue