From 1c3f706383fcd2784ba0a3e8fb8c209898de2ed9 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 1 Apr 2016 22:05:14 -0400 Subject: [PATCH 1/2] AWS: Don't error if there are no ephemeral disks format-disks used to run with non-strict bash semantics, but this changed in 1.2 as we now merge it into the GCE script, so pipefail and errexit are both set. However, the way we list the ephemeral disks, by piping to grep, would cause an exit code of 2 if there were no ephemeral disks. Tolerate failure here by add `|| true`. The metadata service call is unlikely to fail, so we continue to ignore that possibility. --- cluster/aws/templates/format-disks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster/aws/templates/format-disks.sh b/cluster/aws/templates/format-disks.sh index adf3396778d..be0ddc21512 100644 --- a/cluster/aws/templates/format-disks.sh +++ b/cluster/aws/templates/format-disks.sh @@ -26,7 +26,7 @@ fi block_devices=() -ephemeral_devices=$(curl --silent http://169.254.169.254/2014-11-05/meta-data/block-device-mapping/ | grep ephemeral) +ephemeral_devices=$( (curl --silent http://169.254.169.254/2014-11-05/meta-data/block-device-mapping/ | grep ephemeral) || true ) for ephemeral_device in $ephemeral_devices; do echo "Checking ephemeral device: ${ephemeral_device}" aws_device=$(curl --silent http://169.254.169.254/2014-11-05/meta-data/block-device-mapping/${ephemeral_device}) From f43f398cadb86fb50b80171bea816daf9057e415 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 1 Apr 2016 22:09:20 -0400 Subject: [PATCH 2/2] AWS kube-up: Allow BLOCK_DEVICE_MAPPINGS_BASE to be empty We rename it to EPHEMERAL_BLOCK_DEVICE_MAPPINGS, and we also change the value so that it starts with a `,`, instead of always inserting a comma before it. In this way the value can be empty. Also, if the user sets the (currently experimental) KUBE_AWS_STORAGE environment variable to be "ebs", then we will not mount any instance storage which will cause the machines to use EBS storage instead. --- cluster/aws/util.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index 0ec86ddb3de..874088271bb 100755 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -120,10 +120,17 @@ NODE_SG_NAME="kubernetes-minion-${CLUSTER_ID}" # Be sure to map all the ephemeral drives. We can specify more than we actually have. # TODO: Actually mount the correct number (especially if we have more), though this is non-trivial, and # only affects the big storage instance types, which aren't a typical use case right now. -BLOCK_DEVICE_MAPPINGS_BASE="{\"DeviceName\": \"/dev/sdc\",\"VirtualName\":\"ephemeral0\"},{\"DeviceName\": \"/dev/sdd\",\"VirtualName\":\"ephemeral1\"},{\"DeviceName\": \"/dev/sde\",\"VirtualName\":\"ephemeral2\"},{\"DeviceName\": \"/dev/sdf\",\"VirtualName\":\"ephemeral3\"}" +EPHEMERAL_BLOCK_DEVICE_MAPPINGS=",{\"DeviceName\": \"/dev/sdc\",\"VirtualName\":\"ephemeral0\"},{\"DeviceName\": \"/dev/sdd\",\"VirtualName\":\"ephemeral1\"},{\"DeviceName\": \"/dev/sde\",\"VirtualName\":\"ephemeral2\"},{\"DeviceName\": \"/dev/sdf\",\"VirtualName\":\"ephemeral3\"}" + +# Experimental: If the user sets KUBE_AWS_STORAGE to ebs, use ebs storage +# in preference to local instance storage We do this by not mounting any +# instance storage. We could do this better in future (e.g. making instance +# storage available for other purposes) +if [[ "${KUBE_AWS_STORAGE:-}" == "ebs" ]]; then + EPHEMERAL_BLOCK_DEVICE_MAPPINGS="" +fi # TODO (bburns) Parameterize this for multiple cluster per project - function get_vpc_id { $AWS_CMD describe-vpcs \ --filters Name=tag:Name,Values=kubernetes-vpc \ @@ -417,8 +424,8 @@ function detect-root-device { ROOT_DEVICE_NODE=$($AWS_CMD describe-images --image-ids ${node_image} --query 'Images[].RootDeviceName') fi - MASTER_BLOCK_DEVICE_MAPPINGS="[{\"DeviceName\":\"${ROOT_DEVICE_MASTER}\",\"Ebs\":{\"DeleteOnTermination\":true,\"VolumeSize\":${MASTER_ROOT_DISK_SIZE},\"VolumeType\":\"${MASTER_ROOT_DISK_TYPE}\"}}, ${BLOCK_DEVICE_MAPPINGS_BASE}]" - NODE_BLOCK_DEVICE_MAPPINGS="[{\"DeviceName\":\"${ROOT_DEVICE_NODE}\",\"Ebs\":{\"DeleteOnTermination\":true,\"VolumeSize\":${NODE_ROOT_DISK_SIZE},\"VolumeType\":\"${NODE_ROOT_DISK_TYPE}\"}}, ${BLOCK_DEVICE_MAPPINGS_BASE}]" + MASTER_BLOCK_DEVICE_MAPPINGS="[{\"DeviceName\":\"${ROOT_DEVICE_MASTER}\",\"Ebs\":{\"DeleteOnTermination\":true,\"VolumeSize\":${MASTER_ROOT_DISK_SIZE},\"VolumeType\":\"${MASTER_ROOT_DISK_TYPE}\"}} ${EPHEMERAL_BLOCK_DEVICE_MAPPINGS}]" + NODE_BLOCK_DEVICE_MAPPINGS="[{\"DeviceName\":\"${ROOT_DEVICE_NODE}\",\"Ebs\":{\"DeleteOnTermination\":true,\"VolumeSize\":${NODE_ROOT_DISK_SIZE},\"VolumeType\":\"${NODE_ROOT_DISK_TYPE}\"}} ${EPHEMERAL_BLOCK_DEVICE_MAPPINGS}]" } # Computes the AWS fingerprint for a public key file ($1)