Scheduler: add log warning hints

Add hints for log warning messages.

Change-Id: I699ed0bd0ebbea71c3408c2f23472a91b9f6a89a
This commit is contained in:
Gary Kotton 2014-08-03 06:56:42 -07:00
parent e5fbc99af8
commit 38eee0cfd2
7 changed files with 26 additions and 23 deletions

View File

@ -59,7 +59,7 @@ def handle_schedule_error(context, ex, instance_uuid, request_spec):
else:
LOG.exception(_("Exception during scheduler.run_instance"))
state = vm_states.ERROR.upper()
LOG.warning(_('Setting instance to %s state.'), state,
LOG.warning(_LW('Setting instance to %s state.'), state,
instance_uuid=instance_uuid)
(old_ref, new_ref) = db.instance_update_and_get_original(context,

View File

@ -25,7 +25,7 @@ from oslo.config import cfg
from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LW
from nova import objects
from nova.openstack.common import log as logging
from nova import rpc
@ -175,7 +175,7 @@ class FilterScheduler(driver.Scheduler):
updated_instance = driver.instance_update_db(context,
instance_uuid)
except exception.InstanceNotFound:
LOG.warning(_("Instance disappeared during scheduling"),
LOG.warning(_LW("Instance disappeared during scheduling"),
context=context, instance_uuid=instance_uuid)
else:

View File

@ -15,7 +15,7 @@
from oslo.config import cfg
from nova.i18n import _
from nova.i18n import _LW
from nova.openstack.common import log as logging
from nova.scheduler import filters
from nova import servicegroup
@ -44,7 +44,7 @@ class ComputeFilter(filters.BaseHostFilter):
return False
else:
if not self.servicegroup_api.service_is_up(service):
LOG.warn(_("%(host_state)s has not been heard from in a "
"while"), {'host_state': host_state})
LOG.warn(_LW("%(host_state)s has not been heard from in a "
"while"), {'host_state': host_state})
return False
return True

View File

@ -15,7 +15,7 @@
# under the License.
from nova.i18n import _
from nova.i18n import _LW
from nova.openstack.common import log as logging
from nova.scheduler import filters
@ -33,7 +33,7 @@ class ExactCoreFilter(filters.BaseHostFilter):
if not host_state.vcpus_total:
# Fail safe
LOG.warning(_("VCPUs not set; assuming CPU collection broken"))
LOG.warning(_LW("VCPUs not set; assuming CPU collection broken"))
return False
required_vcpus = instance_type['vcpus']

View File

@ -26,7 +26,7 @@ from nova.compute import task_states
from nova.compute import vm_states
from nova import db
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LW
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
@ -167,7 +167,7 @@ class HostState(object):
if name:
self.metrics[name] = item
else:
LOG.warn(_("Metric name unknown of %r") % item)
LOG.warn(_LW("Metric name unknown of %r"), item)
def update_from_compute_node(self, compute):
"""Update information about a host from its compute_node info."""
@ -182,8 +182,8 @@ class HostState(object):
if least_gb is not None:
if least_gb > free_gb:
# can occur when an instance in database is not on host
LOG.warn(_("Host has more disk space than database expected"
" (%(physical)sgb > %(database)sgb)") %
LOG.warn(_LW("Host has more disk space than database "
"expected (%(physical)sgb > %(database)sgb)"),
{'physical': least_gb, 'database': free_gb})
free_gb = min(least_gb, free_gb)
free_disk_mb = free_gb * 1024
@ -394,7 +394,7 @@ class HostManager(object):
for compute in compute_nodes:
service = compute['service']
if not service:
LOG.warn(_("No service for compute ID %s") % compute['id'])
LOG.warn(_LW("No service for compute ID %s"), compute['id'])
continue
host = service['host']
node = compute.get('hypervisor_hostname')

View File

@ -22,7 +22,7 @@ from nova.compute import flavors
from nova.compute import utils as compute_utils
from nova import db
from nova import exception
from nova.i18n import _
from nova.i18n import _, _LW
from nova import notifications
from nova.objects import base as obj_base
from nova.openstack.common import jsonutils
@ -72,7 +72,7 @@ def build_request_spec(ctxt, image, instances, instance_type=None):
def set_vm_state_and_notify(context, service, method, updates, ex,
request_spec, db):
"""changes VM state and notifies."""
LOG.warning(_("Failed to %(service)s_%(method)s: %(ex)s"),
LOG.warning(_LW("Failed to %(service)s_%(method)s: %(ex)s"),
{'service': service, 'method': method, 'ex': ex})
vm_state = updates['vm_state']
@ -88,7 +88,7 @@ def set_vm_state_and_notify(context, service, method, updates, ex,
for instance_uuid in request_spec.get('instance_uuids') or uuids:
if instance_uuid:
state = vm_state.upper()
LOG.warning(_('Setting instance to %s state.'), state,
LOG.warning(_LW('Setting instance to %s state.'), state,
instance_uuid=instance_uuid)
# update instance state and notify on the transition
@ -228,10 +228,10 @@ def parse_options(opts, sep='=', converter=str, name=""):
else:
bad.append(opt)
if bad:
LOG.warn(_("Ignoring the invalid elements of the option "
"%(name)s: %(options)s"),
{'name': name,
'options': ", ".join(bad)})
LOG.warn(_LW("Ignoring the invalid elements of the option "
"%(name)s: %(options)s"),
{'name': name,
'options': ", ".join(bad)})
return good

View File

@ -23,6 +23,7 @@ from nova.compute import task_states
from nova.compute import vm_states
from nova import db
from nova import exception
from nova.i18n import _LW
from nova.openstack.common import jsonutils
from nova.openstack.common import timeutils
from nova.scheduler import filters
@ -281,10 +282,12 @@ class HostManagerTestCase(test.NoDBTestCase):
db.compute_node_get_all(context).AndReturn(fakes.COMPUTE_NODES)
# node 3 host physical disk space is greater than database
host_manager.LOG.warn("Host has more disk space than database expected"
" (3333gb > 3072gb)")
host_manager.LOG.warn(_LW("Host has more disk space than database "
"expected (%(physical)sgb > "
"%(database)sgb)"),
{'physical': 3333, 'database': 3072})
# Invalid service
host_manager.LOG.warn("No service for compute ID 5")
host_manager.LOG.warn(_LW("No service for compute ID %s"), 5)
self.mox.ReplayAll()
self.host_manager.get_all_host_states(context)