Browse code

Only sysctl reserverd ports when available.

Only set the keystone reserved ports when available, on some system
(like when running under containers) where this sysfs interface is not
exposed we are almost pretty sure these ports would be exclusive for our
devstack.

Change-Id: I06d7d227ae94d564c91c16119e4bbbcc6564a280

Chmouel Boudjnah authored on 2014/10/03 03:58:20
Showing 1 changed files
... ...
@@ -50,17 +50,24 @@ fi
50 50
 # exception into the Kernel for the Keystone AUTH ports.
51 51
 keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358}
52 52
 
53
-# Get any currently reserved ports, strip off leading whitespace
54
-reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
55
-
56
-if [[ -z "${reserved_ports}" ]]; then
57
-    # If there are no currently reserved ports, reserve the keystone ports
58
-    sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
53
+# only do the reserved ports when available, on some system (like containers)
54
+# where it's not exposed we are almost pretty sure these ports would be
55
+# exclusive for our devstack.
56
+if sysctl net.ipv4.ip_local_reserved_ports >/dev/null 2>&1; then
57
+    # Get any currently reserved ports, strip off leading whitespace
58
+    reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
59
+
60
+    if [[ -z "${reserved_ports}" ]]; then
61
+        # If there are no currently reserved ports, reserve the keystone ports
62
+        sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
63
+    else
64
+        # If there are currently reserved ports, keep those and also reserve the
65
+        # keystone specific ports. Duplicate reservations are merged into a single
66
+        # reservation (or range) automatically by the kernel.
67
+        sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
68
+    fi
59 69
 else
60
-    # If there are currently reserved ports, keep those and also reserve the
61
-    # keystone specific ports. Duplicate reservations are merged into a single
62
-    # reservation (or range) automatically by the kernel.
63
-    sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
70
+    echo_summary "WARNING: unable to reserve keystone ports"
64 71
 fi
65 72
 
66 73