Github user acvogel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5109#discussion_r27145944
  
    --- Diff: ec2/spark_ec2.py ---
    @@ -528,32 +532,53 @@ def launch_cluster(conn, opts, cluster_name):
                 name = '/dev/sd' + string.letters[i + 1]
                 block_map[name] = dev
     
    -    # Launch slaves
    -    if opts.spot_price is not None:
    -        # Launch spot instances with the requested price
    -        print ("Requesting %d slaves as spot instances with price $%.3f" %
    -               (opts.slaves, opts.spot_price))
    +    # Launch spot instances
    +    if opts.spot_price is not None or opts.master_spot_price is not None:
             zones = get_zones(conn, opts)
    -        num_zones = len(zones)
    -        i = 0
             my_req_ids = []
    -        for zone in zones:
    -            num_slaves_this_zone = get_partition(opts.slaves, num_zones, i)
    -            slave_reqs = conn.request_spot_instances(
    -                price=opts.spot_price,
    +        # Launch slaves
    +        if opts.spot_price is not None:
    +            print ("Requesting %d slaves as spot instances with price 
$%.3f" %
    +                   (opts.slaves, opts.spot_price))
    +            num_zones = len(zones)
    +            i = 0
    +            for zone in zones:
    +                num_slaves_this_zone = get_partition(opts.slaves, 
num_zones, i)
    +                slave_reqs = conn.request_spot_instances(
    +                    price=opts.spot_price,
    +                    image_id=opts.ami,
    +                    launch_group="launch-group-%s" % cluster_name,
    +                    placement=zone,
    +                    count=num_slaves_this_zone,
    +                    key_name=opts.key_pair,
    +                    security_group_ids=[slave_group.id] + 
additional_group_ids,
    +                    instance_type=opts.instance_type,
    +                    block_device_map=block_map,
    +                    subnet_id=opts.subnet_id,
    +                    placement_group=opts.placement_group,
    +                    user_data=user_data_content)
    +                my_req_ids += [req.id for req in slave_reqs]
    +                i += 1
    +        # Launch master
    +        if opts.master_spot_price is not None:
    +            print ("Requesting master as spot instance with price $%.3f" % 
opts.master_spot_price)
    +            master_type = opts.master_instance_type
    +            if master_type == "":
    +                master_type = opts.instance_type
    +            master_reqs = conn.request_spot_instances(
    +                price=opts.master_spot_price,
                     image_id=opts.ami,
                     launch_group="launch-group-%s" % cluster_name,
    -                placement=zone,
    -                count=num_slaves_this_zone,
    +                placement=random.choice(zones),
    --- End diff --
    
    'zones' is set above, in line 548, where it is restricted to those 
consistent with the zones specified by the user. The slaves are evenly 
distributed across the eligible zones, so the master is randomly assigned to 
one of them, each of which should have roughly the same number of slaves.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to