Fix resource exhaustion with upstart.
When high VM churn is encountered dhcp-all-interfaces got tangled up and leaked instances until upstart run out of filedescriptors. This happened because we were locking on every invocation, and the lock logic was disabling the single-interface code - so we always probed every interface every time - and this was serialized across every instance of dhcp-all-interfaces. Change-Id: I4ef1fb83d978cc99d4cb9cc2666bde302c6db7d1
This commit is contained in:
parent
6090f520d1
commit
c7875398b3
@ -14,13 +14,17 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$CONF_TYPE" == "eni" ]; then
|
||||
# Serialize runs so that we don't miss hot-add interfaces
|
||||
FLOCKED=${FLOCKED:-}
|
||||
if [ -z "$FLOCKED" ] ; then
|
||||
FLOCKED=true exec flock -x $ENI_FILE $0
|
||||
fi
|
||||
fi
|
||||
ARGS="$0 $@"
|
||||
|
||||
function serialize_me() {
|
||||
if [ "$CONF_TYPE" == "eni" ]; then
|
||||
# Serialize runs so that we don't miss hot-add interfaces
|
||||
FLOCKED=${FLOCKED:-}
|
||||
if [ -z "$FLOCKED" ] ; then
|
||||
FLOCKED=true exec flock -x $ENI_FILE $ARGS
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function get_if_link() {
|
||||
cat /sys/class/net/${1}/carrier
|
||||
@ -29,6 +33,7 @@ function get_if_link() {
|
||||
function enable_interface() {
|
||||
local interface=$1
|
||||
|
||||
serialize_me
|
||||
if [ "$CONF_TYPE" == "eni" ]; then
|
||||
printf "auto $interface\niface $interface inet dhcp\n\n" >>$ENI_FILE
|
||||
elif [ "$CONF_TYPE" == "netscripts" ]; then
|
||||
@ -41,6 +46,7 @@ function enable_interface() {
|
||||
function disable_interface() {
|
||||
local interface=$1
|
||||
|
||||
serialize_me
|
||||
if [ "$CONF_TYPE" == "netscripts" ]; then
|
||||
local IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-$interface"
|
||||
if [ -f "$IFCFG_FILE" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user