From 3fb52fa360e3aaaf7e2802b0e7afa9328278fda4 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Wed, 21 Sep 2016 16:03:11 -0700 Subject: [PATCH] ifupdown: scheduler: ignore errors generated by upperiface bring up Ticket: CM-12923 Reviewed By: julien, nikhil Testing Done: tested implicit upperiface bring up upperiface bringup is best effort, so ignore errors. $ifquery -c -a ..[snip]... auto br0 iface br0 bridge-vlan-aware yes [pass] bridge-ports vx-14 vx-11 vx-10 vx-13 vx-12 [pass] $ifdown vx-10 $ifdown vx-11 before patch: $ifup vx-10 ..[snip]... info: running upperifaces (parent interfaces) if available .. info: br0: running ops ... error: br0: bridge port vx-11 does not exist .... After patch: $ifup vx-10 ..[snip]... info: running upperifaces (parent interfaces) if available .. info: br0: running ops ... .... Signed-off-by: Roopa Prabhu --- ifupdown/ifupdownflags.py | 1 + ifupdown/scheduler.py | 13 ++++++++++++- ifupdownaddons/modulebase.py | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ifupdown/ifupdownflags.py b/ifupdown/ifupdownflags.py index 4be891a..d76e733 100644 --- a/ifupdown/ifupdownflags.py +++ b/ifupdown/ifupdownflags.py @@ -17,6 +17,7 @@ class ifupdownFlags(): self.PERFMODE = False self.CACHE = False self.WITHDEFAULTS = False + self.IGNORE_ERRORS = False # Flags self.CACHE_FLAGS = 0x0 diff --git a/ifupdown/scheduler.py b/ifupdown/scheduler.py index c79278f..22d32a5 100644 --- a/ifupdown/scheduler.py +++ b/ifupdown/scheduler.py @@ -567,10 +567,21 @@ class ifaceScheduler(): ifupdownobj.logger.info('running upperifaces (parent interfaces) ' + 'if available ..') try: + # upperiface bring up is best effort. + # eg case: if we are bringing up a bridge port + # this section does an 'ifup on the bridge' + # so that the recently up'ed bridge port gets enslaved + # to the bridge. But the up on the bridge may + # throw out more errors if the bridge is not + # in the correct state. Lets not surprise + # the user with such errors when he has + # only requested to bring up the bridge port. cls._STATE_CHECK = False + ifupdownflags.flags.IGNORE_ERRORS = True cls.run_upperifaces(ifupdownobj, ifacenames, ops) - cls._STATE_CHECK = True finally: + ifupdownflags.flags.IGNORE_ERRORS = False + cls._STATE_CHECK = True # upperiface bringup is best effort, so dont propagate errors # reset scheduler status to True cls.set_sched_status(True) diff --git a/ifupdownaddons/modulebase.py b/ifupdownaddons/modulebase.py index 5ca6835..5b7840a 100644 --- a/ifupdownaddons/modulebase.py +++ b/ifupdownaddons/modulebase.py @@ -42,7 +42,7 @@ class moduleBase(object): def log_warn(self, str, ifaceobj=None): """ log a warning if err str is not one of which we should ignore """ - if not self.ignore_error(str): + if not self.ignore_error(str) and not ifupdownflags.flags.IGNORE_ERRORS: if self.logger.getEffectiveLevel() == logging.DEBUG: traceback.print_stack() self.logger.warn(str) @@ -52,7 +52,7 @@ class moduleBase(object): def log_error(self, str, ifaceobj=None, raise_error=True): """ log an err if err str is not one of which we should ignore and raise an exception """ - if not self.ignore_error(str): + if not self.ignore_error(str) and not ifupdownflags.flags.IGNORE_ERRORS: if self.logger.getEffectiveLevel() == logging.DEBUG: traceback.print_stack() if raise_error: