Skip to content

Commit 1725a1a

Browse files
committed
[SPARK-3391][EC2] Support attaching up to 8 EBS volumes.
Please merge this at the same time as mesos/spark-ec2#66 Author: Reynold Xin <[email protected]> Closes apache#2260 from rxin/ec2-ebs-vol and squashes the following commits: b9527d9 [Reynold Xin] Removed io1 ebs type. bf9c403 [Reynold Xin] Made EBS volume type configurable. c8e25ea [Reynold Xin] Support up to 8 EBS volumes. adf4f2e [Reynold Xin] Revert git repo change. 020c542 [Reynold Xin] [SPARK-3391] Support attaching more than 1 EBS volumes.
1 parent 1904bac commit 1725a1a

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

ec2/spark_ec2.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,17 @@ def parse_args():
102102
"(for debugging)")
103103
parser.add_option(
104104
"--ebs-vol-size", metavar="SIZE", type="int", default=0,
105-
help="Attach a new EBS volume of size SIZE (in GB) to each node as " +
106-
"/vol. The volumes will be deleted when the instances terminate. " +
107-
"Only possible on EBS-backed AMIs.")
105+
help="Size (in GB) of each EBS volume.")
106+
parser.add_option(
107+
"--ebs-vol-type", default="standard",
108+
help="EBS volume type (e.g. 'gp2', 'standard').")
109+
parser.add_option(
110+
"--ebs-vol-num", type="int", default=1,
111+
help="Number of EBS volumes to attach to each node as /vol[x]. " +
112+
"The volumes will be deleted when the instances terminate. " +
113+
"Only possible on EBS-backed AMIs. " +
114+
"EBS volumes are only attached if --ebs-vol-size > 0." +
115+
"Only support up to 8 EBS volumes.")
108116
parser.add_option(
109117
"--swap", metavar="SWAP", type="int", default=1024,
110118
help="Swap space to set up per node, in MB (default: 1024)")
@@ -348,13 +356,16 @@ def launch_cluster(conn, opts, cluster_name):
348356
print >> stderr, "Could not find AMI " + opts.ami
349357
sys.exit(1)
350358

351-
# Create block device mapping so that we can add an EBS volume if asked to
359+
# Create block device mapping so that we can add EBS volumes if asked to.
360+
# The first drive is attached as /dev/sds, 2nd as /dev/sdt, ... /dev/sdz
352361
block_map = BlockDeviceMapping()
353362
if opts.ebs_vol_size > 0:
354-
device = EBSBlockDeviceType()
355-
device.size = opts.ebs_vol_size
356-
device.delete_on_termination = True
357-
block_map["/dev/sdv"] = device
363+
for i in range(opts.ebs_vol_num):
364+
device = EBSBlockDeviceType()
365+
device.size = opts.ebs_vol_size
366+
device.volume_type=opts.ebs_vol_type
367+
device.delete_on_termination = True
368+
block_map["/dev/sd" + chr(ord('s') + i)] = device
358369

359370
# AWS ignores the AMI-specified block device mapping for M3 (see SPARK-3342).
360371
if opts.instance_type.startswith('m3.'):
@@ -828,6 +839,12 @@ def get_partition(total, num_partitions, current_partitions):
828839

829840
def real_main():
830841
(opts, action, cluster_name) = parse_args()
842+
843+
# Input parameter validation
844+
if opts.ebs_vol_num > 8:
845+
print >> stderr, "ebs-vol-num cannot be greater than 8"
846+
sys.exit(1)
847+
831848
try:
832849
conn = ec2.connect_to_region(opts.region)
833850
except Exception as e:

0 commit comments

Comments
 (0)