Skip to content

Commit

Permalink
Merge "Update controller logging"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 21, 2015
2 parents 833d633 + 55ad390 commit a474130
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
8 changes: 5 additions & 3 deletions octavia/cmd/house_keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def spare_amphora_check():

spare_amp = house_keeping.SpareAmphora()
while spare_amp_thread_event.is_set():
LOG.info(_LI("Initiating spare amphora check..."))
LOG.debug("Initiating spare amphora check...")
spare_amp.spare_check()
time.sleep(interval)

Expand All @@ -52,10 +52,12 @@ def db_cleanup():
# Read the interval from CONF
interval = CONF.house_keeping.cleanup_interval
LOG.info(_LI("DB cleanup interval is set to %d sec") % interval)
LOG.info(_LI('Amphora expiry age is %s seconds') %
CONF.house_keeping.amphora_expiry_age)

db_cleanup = house_keeping.DatabaseCleanup()
while db_cleanup_thread_event.is_set():
LOG.info(_LI("Initiating the cleanup of old amphora..."))
LOG.debug("Initiating the cleanup of old amphora...")
db_cleanup.delete_old_amphorae()
time.sleep(interval)

Expand Down Expand Up @@ -88,4 +90,4 @@ def main():
db_cleanup_thread_event.clear()
spare_amp_thread.join()
db_cleanup_thread.join()
LOG.info(_LI("House-Keeping process terminated"))
LOG.info(_LI("House-Keeping process terminated"))
15 changes: 7 additions & 8 deletions octavia/controller/housekeeping/house_keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ def spare_check(self):
session = db_api.get_session()
conf_spare_cnt = CONF.house_keeping.spare_amphora_pool_size
curr_spare_cnt = self.amp_repo.get_spare_amphora_count(session)
LOG.info(_LI("Required Spare Amphora count : %d") % conf_spare_cnt)
LOG.info(_LI("Current Spare Amphora count : %d") % curr_spare_cnt)
LOG.debug("Required Spare Amphora count : %d" % conf_spare_cnt)
LOG.debug("Current Spare Amphora count : %d" % curr_spare_cnt)
diff_count = conf_spare_cnt - curr_spare_cnt

# When the current spare amphora is less than required
if diff_count > 0:
LOG.info(_LI("Current spare amphora are fewer than required"))
LOG.info(_LI("Initiating creation of %d amphora ...") % diff_count)
LOG.info(_LI("Initiating creation of %d spare amphora.") %
diff_count)

# Call Amphora Create Flow diff_count times
for i in range(1, diff_count + 1):
LOG.info(_LI("Starting amphorae number %d ...") % i)
LOG.debug("Starting amphorae number %d ..." % i)
self.cw.create_amphora()

else:
LOG.info(_LI("Current spare amphora count satisfies the "
"requirement"))
LOG.debug(_LI("Current spare amphora count satisfies the "
"requirement"))


class DatabaseCleanup(object):
Expand All @@ -69,7 +69,6 @@ def delete_old_amphorae(self):
"""Checks the DB for old amphora and deletes them based on it's age."""
exp_age = datetime.timedelta(
seconds=CONF.house_keeping.amphora_expiry_age)
LOG.info(_LI('Amphora expiry age is %s seconds') % exp_age)

session = db_api.get_session()
amphora = self.amp_repo.get_all(session, status=constants.DELETED)
Expand Down
26 changes: 14 additions & 12 deletions octavia/controller/worker/tasks/database_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from octavia.common import exceptions
from octavia.db import api as db_apis
from octavia.db import repositories as repo
from octavia.i18n import _LW
from octavia.i18n import _LI, _LW

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -56,7 +56,7 @@ def execute(self, *args, **kwargs):
id=uuidutils.generate_uuid(),
status=constants.PENDING_CREATE)

LOG.debug("Created Amphora in DB with id %s" % amphora.id)
LOG.info(_LI("Created Amphora in DB with id %s") % amphora.id)
return amphora.id

def revert(self, result, *args, **kwargs):
Expand Down Expand Up @@ -292,8 +292,8 @@ def execute(self, loadbalancer_id):
loadbalancer_id)
raise exceptions.NoReadyAmphoraeException()

LOG.debug("Allocated Amphora with id %s for load balancer "
"with id %s" % (amp.id, loadbalancer_id))
LOG.info(_LI("Allocated Amphora with id %(amp)s for load balancer "
"with id %(lb)s") % {"amp": amp.id, "lb": loadbalancer_id})

return amp.id

Expand All @@ -308,9 +308,10 @@ class MarkAmphoraAllocatedInDB(BaseDatabaseTask):
def execute(self, amphora, loadbalancer_id):
"""Mark amphora as allocated to a load balancer in DB."""

LOG.debug("Mark ALLOCATED in DB for amphora: %s with compute id %s "
"for load balancer: %s" %
(amphora.id, amphora.compute_id, loadbalancer_id))
LOG.info(_LI("Mark ALLOCATED in DB for amphora: %(amp)s with "
"compute id %(comp)s for load balancer: %(lb)s") %
{"amp": amphora.id, "comp": amphora.compute_id,
"lb": loadbalancer_id})
self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.AMPHORA_ALLOCATED,
compute_id=amphora.compute_id,
Expand Down Expand Up @@ -441,8 +442,9 @@ class MarkAmphoraReadyInDB(BaseDatabaseTask):
def execute(self, amphora):
"""Mark amphora as ready in DB."""

LOG.debug("Mark BOOTING in DB for amphora: %s with compute id %s" %
(amphora.id, amphora.compute_id))
LOG.info(_LI("Mark READY in DB for amphora: %(amp)s with compute "
"id %(comp)s") % {"amp": amphora.id,
"comp": amphora.compute_id})
self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.AMPHORA_READY,
compute_id=amphora.compute_id,
Expand Down Expand Up @@ -484,8 +486,8 @@ class MarkLBActiveInDB(BaseDatabaseTask):
def execute(self, loadbalancer):
"""Mark the load balancer as active in DB."""

LOG.debug("Mark ACTIVE in DB for load balancer id: %s" %
loadbalancer.id)
LOG.info(_LI("Mark ACTIVE in DB for load balancer id: %s") %
loadbalancer.id)
self.loadbalancer_repo.update(db_apis.get_session(),
loadbalancer.id,
provisioning_status=constants.ACTIVE)
Expand Down Expand Up @@ -854,4 +856,4 @@ class GetVipFromLoadbalancer(BaseDatabaseTask):
"""Task to pull the vip from a loadbalancer."""

def execute(self, loadbalancer):
return loadbalancer.vip
return loadbalancer.vip

0 comments on commit a474130

Please sign in to comment.