From 6757a9c5dec32f39b984ceaaa0eb9e903602769a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Fri, 21 Dec 2018 13:17:05 +0100 Subject: [PATCH] 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 --- lib/etcd3 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/etcd3 b/lib/etcd3 index c65a522267..0748ea01ee 100644 --- a/lib/etcd3 +++ b/lib/etcd3 @@ -27,6 +27,10 @@ set +o xtrace ETCD_DATA_DIR="$DATA_DIR/etcd" ETCD_SYSTEMD_SERVICE="devstack@etcd.service" ETCD_BIN_DIR="$DEST/bin" +# Option below will mount ETCD_DATA_DIR as ramdisk, which is useful to run +# etcd-heavy services in the gate VM's, e.g. Kubernetes. +ETCD_USE_RAMDISK=$(trueorfalse False ETCD_USE_RAMDISK) +ETCD_RAMDISK_MB=${ETCD_RAMDISK_MB:-512} if is_ubuntu ; then UBUNTU_RELEASE_BASE_NUM=`lsb_release -r | awk '{print $2}' | cut -d '.' -f 1` @@ -89,6 +93,9 @@ function cleanup_etcd3 { $SYSTEMCTL daemon-reload + if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then + sudo umount $ETCD_DATA_DIR + fi sudo rm -rf $ETCD_DATA_DIR } @@ -98,6 +105,9 @@ function install_etcd3 { # Create the necessary directories sudo mkdir -p $ETCD_BIN_DIR sudo mkdir -p $ETCD_DATA_DIR + if [[ "$ETCD_USE_RAMDISK" == "True" ]]; then + sudo mount -t tmpfs -o nodev,nosuid,size=${ETCD_RAMDISK_MB}M tmpfs $ETCD_DATA_DIR + fi # Download and cache the etcd tgz for subsequent use local etcd_file