dist/common/scripts: move EC2 configuration verification to 'scylla_ec2_check'

Currently we only have EC2 configuration verification on AMI, so move it to
/usr/lib/scylla and run it from scylla_setup, to make it usable for
non-AMI users.

Fixes #1997

Signed-off-by: Takuya ASADA <syuu@scylladb.com>
Message-Id: <1498811107-29135-1-git-send-email-syuu@scylladb.com>
This commit is contained in:
Takuya ASADA
2017-06-30 17:25:07 +09:00
committed by Avi Kivity
parent 6895f6e603
commit e645b0fb13
5 changed files with 76 additions and 46 deletions

View File

@@ -13,27 +13,6 @@ PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
get_en_interface_type() {
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 1`
SUBTYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 2`
case $TYPE in
"c3"|"c4"|"d2"|"i2"|"r3") echo -n "ixgbevf";;
"i3"|"p2"|"r4"|"x1") echo -n "ena";;
"m4")
if [ "$SUBTYPE" = "16xlarge" ]; then
echo -n "ena"
else
echo -n "ixgbevf"
fi;;
esac
}
is_vpc_enabled() {
MAC=`cat /sys/class/net/eth0/address`
VPC_AVAIL=`curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/|grep vpc-id`
[ -n "$VPC_AVAIL" ]
}
echo
echo ' _____ _ _ _____ ____ '
echo ' / ____| | | | | __ \| _ \ '
@@ -130,28 +109,8 @@ else
fi
fi
fi
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type`
EN=`get_en_interface_type`
DRIVER=`ethtool -i eth0|awk '/^driver:/ {print $2}'`
if [ "$EN" = "" ]; then
tput setaf 1
tput bold
echo " $TYPE doesn't support enahanced networking!"
tput sgr0
echo "To enable enhanced networking, please use the instance type which supports it."
echo "More documentation available at: "
echo "http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking"
elif ! is_vpc_enabled; then
tput setaf 1
tput bold
echo " VPC is not enabled!"
tput sgr0
echo "To enable enhanced networking, please enable VPC."
elif [ "$DRIVER" != "$EN" ]; then
tput setaf 1
tput bold
echo " Enhanced networking is disabled!"
tput sgr0
echo "More documentation available at: "
echo "http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html"
echo -n " "
/usr/lib/scylla/scylla_ec2_check
if [ $? -eq 0 ]; then
echo
fi

1
dist/common/sbin/scylla_ec2_check vendored Symbolic link
View File

@@ -0,0 +1 @@
/usr/lib/scylla/scylla_ec2_check

57
dist/common/scripts/scylla_ec2_check vendored Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
. /usr/lib/scylla/scylla_lib.sh
get_en_interface_type() {
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 1`
SUBTYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 2`
case $TYPE in
"c3"|"c4"|"d2"|"i2"|"r3") echo -n "ixgbevf";;
"i3"|"p2"|"r4"|"x1") echo -n "ena";;
"m4")
if [ "$SUBTYPE" = "16xlarge" ]; then
echo -n "ena"
else
echo -n "ixgbevf"
fi;;
esac
}
is_vpc_enabled() {
MAC=`cat /sys/class/net/eth0/address`
VPC_AVAIL=`curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/|grep vpc-id`
[ -n "$VPC_AVAIL" ]
}
if ! is_ec2; then
exit 0
fi
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type`
EN=`get_en_interface_type`
DRIVER=`ethtool -i eth0|awk '/^driver:/ {print $2}'`
if [ "$EN" = "" ]; then
tput setaf 1
tput bold
echo "$TYPE doesn't support enahanced networking!"
tput sgr0
echo "To enable enhanced networking, please use the instance type which supports it."
echo "More documentation available at: "
echo "http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking"
exit 1
elif ! is_vpc_enabled; then
tput setaf 1
tput bold
echo "VPC is not enabled!"
tput sgr0
echo "To enable enhanced networking, please enable VPC."
exit 1
elif [ "$DRIVER" != "$EN" ]; then
tput setaf 1
tput bold
echo "Enhanced networking is disabled!"
tput sgr0
echo "More documentation available at: "
echo "http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html"
exit 1
fi

View File

@@ -14,13 +14,14 @@ if [ "`id -u`" -ne 0 ]; then
fi
print_usage() {
echo "scylla_setup --disks /dev/hda,/dev/hdb... --nic eth0 --ntp-domain centos --ami --setup-nic --developer-mode --no-kernel-check --no-verify-package --no-enable-service --no-selinux-setup --no-bootparam-setup --no-ntp-setup --no-raid-setup --no-coredump-setup --no-sysconfig-setup --no-cpuscaling-setup --no-fstrim-setup"
echo "scylla_setup --disks /dev/hda,/dev/hdb... --nic eth0 --ntp-domain centos --ami --setup-nic --developer-mode --no-ec2-check --no-kernel-check --no-verify-package --no-enable-service --no-selinux-setup --no-bootparam-setup --no-ntp-setup --no-raid-setup --no-coredump-setup --no-sysconfig-setup --no-cpuscaling-setup --no-fstrim-setup"
echo " --disks specify disks for RAID"
echo " --nic specify NIC"
echo " --ntp-domain specify NTP domain"
echo " --ami setup AMI instance"
echo " --setup-nic optimize NIC queue"
echo " --developer-mode enable developer mode"
echo " --no-ec2-check skip EC2 configuration check(only on EC2)"
echo " --no-kernel-check skip kernel version check"
echo " --no-verify-package skip verifying packages"
echo " --no-enable-service skip enabling service"
@@ -124,6 +125,7 @@ run_setup_script() {
AMI=0
SET_NIC=0
DEV_MODE=0
EC2_CHECK=1
KERNEL_CHECK=1
VERIFY_PACKAGE=1
ENABLE_SERVICE=1
@@ -247,6 +249,16 @@ fi
printf "${GREEN}Skip any of the following steps by answering 'no'${NO_COLOR}\n"
if is_ec2; then
if [ $INTERACTIVE -eq 1 ]; then
interactive_ask_service "Do you want to run Amazon EC2 configuration check?" "Answer yes to have this script verify that current instance configuration is optimized for running Scylla; answer no to skip this check." "yes" &&:
EC2_CHECK=$?
fi
if [ $EC2_CHECK -eq 1 ]; then
/usr/lib/scylla/scylla_ec2_check
fi
fi
if [ $INTERACTIVE -eq 1 ]; then
interactive_ask_service "Do you want to run kernel version check?" "Answer yes to have this script verify that the currently installed kernel is qualified to run Scylla; answer no to skip this check." "yes" &&:
KERNEL_CHECK=$?

View File

@@ -206,6 +206,7 @@ rm -rf $RPM_BUILD_ROOT
%{_prefix}/lib/scylla/scylla_selinux_setup
%{_prefix}/lib/scylla/scylla_io_setup
%{_prefix}/lib/scylla/scylla_dev_mode_setup
%{_prefix}/lib/scylla/scylla_ec2_check
%{_prefix}/lib/scylla/scylla_kernel_check
%{_prefix}/lib/scylla/scylla_cpuset_setup
%{_prefix}/lib/scylla/scylla_cpuscaling_setup