From: Kanzhe Jiang Date: Thu, 22 Jan 2015 07:32:12 +0000 (-0800) Subject: Ignore 404 error and lower a warning log to info X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=705b76d02db318ecedcbd96d09af9785f14429ee;p=openstack-build%2Fneutron-build.git Ignore 404 error and lower a warning log to info Ignore an expected 404 error. Lower the severity of an informational log entry from warning to info to avoid polluting the server.log Closes-Bug: #1413457 Change-Id: Ib6316cdda0aed10d8f430790b0c4f909ad833eb0 --- diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py index b71c73761..474167dc6 100644 --- a/neutron/plugins/bigswitch/servermanager.py +++ b/neutron/plugins/bigswitch/servermanager.py @@ -511,11 +511,11 @@ class ServerPool(object): LOG.error(errstr, resp[2]) raise RemoteRestError(reason=resp[2], status=resp[0]) if resp[0] in ignore_codes: - LOG.warning(_LW("NeutronRestProxyV2: Received and ignored error " - "code %(code)s on %(action)s action to resource " - "%(resource)s"), - {'code': resp[2], 'action': action, - 'resource': resource}) + LOG.info(_LI("NeutronRestProxyV2: Received and ignored error " + "code %(code)s on %(action)s action to resource " + "%(resource)s"), + {'code': resp[2], 'action': action, + 'resource': resource}) return resp def rest_create_router(self, tenant_id, router): @@ -606,7 +606,10 @@ class ServerPool(object): def rest_get_switch(self, switch_id): resource = SWITCHES_PATH % switch_id errstr = _("Unable to retrieve switch: %s") - return self.rest_action('GET', resource, errstr=errstr) + resp = self.rest_action('GET', resource, errstr=errstr, + ignore_codes=[404]) + # return None if switch not found, else return switch info + return None if resp[0] == 404 else resp[3] def _consistency_watchdog(self, polling_interval=60): if 'consistency' not in self.get_capabilities(): diff --git a/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py b/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py index c3d61fcd7..165c18357 100644 --- a/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py +++ b/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py @@ -183,15 +183,11 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base, pass try: - self.servers.rest_get_switch(host) - exists = True - except servermanager.RemoteRestError as e: - if e.status == 404: - exists = False - else: - # Another error, return without caching to try again on - # next binding - return + exists = bool(self.servers.rest_get_switch(host)) + except servermanager.RemoteRestError: + # Connectivity or internal server error. Skip cache to try again on + # next binding attempt + return self.ivs_host_cache[host] = { 'timestamp': datetime.datetime.now(), 'exists': exists