Browse code

Add option to place etcd data dir on RAM disk

Seems like for etcd-heavy services like Kubernetes, the fsync
performance of gate VM's are too low [1]. This commit implements an
option to put etcd data directory on RAM disk (tmpfs) to work this
around.

[1] http://lists.openstack.org/pipermail/openstack-discuss/2019-January/001849.html

Change-Id: I5a17099cb9d6941b1a009dc82daefd2c7946d892

MichaƂ Dulko authored on 2018/12/21 21:17:05
Showing 1 changed files
... ...
@@ -27,6 +27,10 @@ set +o xtrace
27 27
 ETCD_DATA_DIR="$DATA_DIR/etcd"
28 28
 ETCD_SYSTEMD_SERVICE="devstack@etcd.service"
29 29
 ETCD_BIN_DIR="$DEST/bin"
30
+# Option below will mount ETCD_DATA_DIR as ramdisk, which is useful to run
31
+# etcd-heavy services in the gate VM's, e.g. Kubernetes.
32
+ETCD_USE_RAMDISK=$(trueorfalse False ETCD_USE_RAMDISK)
33
+ETCD_RAMDISK_MB=${ETCD_RAMDISK_MB:-512}
30 34
 
31 35
 if is_ubuntu ; then
32 36
     UBUNTU_RELEASE_BASE_NUM=`lsb_release -r | awk '{print $2}' | cut -d '.' -f 1`
... ...
@@ -89,6 +93,9 @@ function cleanup_etcd3 {
89 89
 
90 90
     $SYSTEMCTL daemon-reload
91 91
 
92
+    if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then
93
+        sudo umount $ETCD_DATA_DIR
94
+    fi
92 95
     sudo rm -rf $ETCD_DATA_DIR
93 96
 }
94 97
 
... ...
@@ -98,6 +105,9 @@ function install_etcd3 {
98 98
     # Create the necessary directories
99 99
     sudo mkdir -p $ETCD_BIN_DIR
100 100
     sudo mkdir -p $ETCD_DATA_DIR
101
+    if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then
102
+        sudo mount -t tmpfs -o nodev,nosuid,size=${ETCD_RAMDISK_MB}M tmpfs $ETCD_DATA_DIR
103
+    fi
101 104
 
102 105
     # Download and cache the etcd tgz for subsequent use
103 106
     local etcd_file