From 34cdd4a39c15e7556b28c20f8937f244ac94b68d Mon Sep 17 00:00:00 2001 From: Satish Ashok Date: Thu, 30 Jul 2015 15:01:24 -0700 Subject: [PATCH] break down the bridge port batch add in ifupdown2 Ticket: CM-6496 Reviewed By: CCR-3196 Testing Done: The "ip batch command to add a bridge port and flush the dev" command with 1k netdevices was taking 1.4G of memory. With 2k netdevices batch, this command was causing a OOM condition. To avoid this, commit the batch after 250 ports. Ideally we have to look at the internal batch implementation to see if there is an underlying issue. --- addons/bridge.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/bridge.py b/addons/bridge.py index 421cd30..1c52f27 100644 --- a/addons/bridge.py +++ b/addons/bridge.py @@ -311,6 +311,7 @@ class bridge(moduleBase): self.ipcmd.batch_commit() return err = 0 + ports = 0 for bridgeport in Set(bridgeports).difference(Set(runningbridgeports)): try: if not self.DRYRUN and not self.ipcmd.link_exists(bridgeport): @@ -326,6 +327,11 @@ class bridge(moduleBase): continue self.ipcmd.link_set(bridgeport, 'master', ifaceobj.name) self.ipcmd.addr_flush(bridgeport) + ports += 1 + if ports == 250: + ports = 0 + self.ipcmd.batch_commit() + self.ipcmd.batch_start() except Exception, e: self.logger.error(str(e)) pass