vjagadish1989 commented on a change in pull request #62: Adding support for lxc on yarn for Samza URL: https://github.com/apache/samza-hello-samza/pull/62#discussion_r293128724
########## File path: bin/setup-lxc ########## @@ -0,0 +1,345 @@ +#!/bin/bash -e +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This script will download, setup, start, and stop servers for Kafka, YARN, and ZooKeeper, +# as well as downloading, building and locally publishing Samza + + +COMMAND=$1 +ARG0=$2 +ARG1=$3 + +SHARED_LXC_DIR=/lxc-shared +POSSIBLE_LXC_INTERFACES=( virbr0 lxcbr0) +YARN_SITE_XML=conf/yarn-site.xml +NM_LIVENESS_MS=10000 #value of the yarn.nm.liveness-monitor.expiry-interval-ms variable +LXC_INSTANCE_TYPE="fedora" +LXC_ROOTFS_DIR=/var/lib/lxc +LXC_INSTANCE_START_NM_SCRIPT=startNodeManager + +RESOLV_CONF_FILE=/etc/resolv.conf + +# Helper function to test an IP address for validity: +# Usage: +# valid_ip IP_ADDRESS +# if [[ $? -eq 0 ]]; then echo good; else echo bad; fi +# OR +# if valid_ip IP_ADDRESS; then echo good; else echo bad; fi +# +function valid_ip() +{ + local ip=$1 + local stat=1 + + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ + && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + stat=$? + fi + return $stat +} + +function check_OS() +{ + #Check if OS is linux + if [[ "$OSTYPE" == "linux-gnu" ]]; then + echo "OS check passed." + else + echo "Only RHEL-Linux is currently supported for this setup. Exiting ..." + exit 0 + fi +} + + +function lxc_setup() +{ + + #Install LXC (and its dependencies) + echo "Beginning installation. Installing lxc on your machine" + sudo yum -y install epel-release + sudo yum -y install lxc lxc-templates libcap-devel libcgroup wget bridge-utils lxc-extra --skip-broken + echo "LXC installation complete." + + + lxcInterface="" + gatewayIP="" + + for interface in ${POSSIBLE_LXC_INTERFACES[@]} + do + echo "Checking if $interface is valid" + ip_address=`ip addr show $interface | grep "inet\b" | awk '{print $2}' | cut -d/ -f1` + + if valid_ip $ip_address; then + echo "Interface $interface is valid for using with LXC instances." + lxcInterface=$interface + gatewayIP=$ip_address + break; + else + echo "Interface $interface does not appear to be valid." + continue; Review comment: this loop will continue anyways to check for the next interface. don't think you need a continue here ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services