1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

Introduce a lock file in non-persistent storage /run/network/ifstatelock

to make sure the state file in persistent storage is cleaned up
correctly

Ticket: CM-7774
Reviewed By: CCR-3623
Testing Done: Tested statefile accross reboots

ifupdown2 state file was moved to /var/tmp because /var/tmp was tmpfs
and was large enough (100MB) for the state file. But it appears it has
changed (or is not consistent) across all platforms. We can move it
under /run, but /run again size varies on various platforms and it is
too small on some platforms.

This patch:
- continues to keep the ifupdown2 state file under /var/tmp (because it
needs the space)
- ntroduces a second level /run/network/ifstatelock file that stays on
non-persistant storage and is used to delete the state file at /boot up
This commit is contained in:
Roopa Prabhu
2015-10-02 12:31:51 -07:00
parent 97a907c5fe
commit a33e94f72b
2 changed files with 17 additions and 3 deletions

View File

@@ -58,6 +58,12 @@ class stateManager():
state_filename = 'ifstatenew'
"""name of the satefile """
state_rundir = '/run/network/'
"""name of the state run dir """
state_runlockfile = 'ifstatelock'
"""name of the state run lock file """
def __init__(self):
""" Initializes statemanager internal state
@@ -68,6 +74,8 @@ class stateManager():
self.__class__.__name__)
if not os.path.exists(self.state_dir):
os.mkdir(self.state_dir)
if not os.path.exists(self.state_rundir):
os.mkdir(self.state_rundir)
self.state_file = self.state_dir + self.state_filename
def save_ifaceobj(self, ifaceobj):
@@ -146,6 +154,7 @@ class stateManager():
self.logger.debug('saving state ..')
for ifaceobjs in self.ifaceobjdict.values():
[pickling.save_obj(f, i) for i in ifaceobjs]
open('%s/%s' %(self.state_rundir, self.state_runlockfile), 'w').close()
except:
raise

View File

@@ -11,7 +11,10 @@
PATH="/sbin:/bin"
RUN_DIR="/run/network"
IFSTATE="$RUN_DIR/ifstate"
IFSTATE_LOCKFILE="${RUN_DIR}/ifstatelock"
STATE_DIR="/var/tmp/network"
IFSTATE_FILE="${STATE_DIR}/ifstatenew"
NAME=networking
SCRIPTNAME=/etc/init.d/$NAME
@@ -37,7 +40,7 @@ gen_examples() {
#
# generate files only at boot
[ -f /var/tmp/network/ifstatenew ] && return
[ -f ${IFSTATE_LOCKFILE} ] && return
python_ifupdown2_docdir="/usr/share/doc/python-ifupdown2"
swpfile=${python_ifupdown2_docdir}"/examples/swp_defaults"
@@ -52,7 +55,7 @@ gen_examples() {
perf_options() {
# At bootup lets set perfmode
[ -f /var/tmp/network/ifstatenew ] && echo -n "" && return
[ -f ${IFSTATE_LOCKFILE} ] && echo -n "" && return
echo -n "--perfmode"
}
@@ -124,6 +127,8 @@ ifup_hotplug () {
}
ifupdown_init() {
# remove state file at boot
[ ! -e ${IFSTATE_LOCKFILE} ] && rm -f ${IFSTATE_FILE}
[ ! -e /run/network ] && mkdir -p /run/network &>/dev/null
[ ! -e /etc/network/run ] && \
ln -sf /run/network /etc/network/run &>/dev/null