Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

AWS EC2 - Automatically chosen subnet does not match parametrized AZ

Aperta
#428 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
aws, python

Direzione di ricerca

Inizia in dask_cloudprovider/aws/ec2.py e segui la chiamata a dask_cloudprovider.aws.helper.get_vpc_subnets, quindi esegui la riproduzione di EC2Cluster dell’issue con una availability zone parametrizzata. È completato quando la subnet selezionata automaticamente appartiene a quella availability zone e l’esempio non fallisce più con un errore InvalidParameterValue dovuto a una mancata corrispondenza tra subnet e AZ.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the issue:

ec2.py chooses the first subnet from the specified (or default, if none specified) VPC, ignoring the availability_zone(AZ) parameter.

Some VMs are not supported on all AZs, so it is necessary to provide an AZ, but doing so may conflict with the subnet selected on the step described above.

Minimal Complete Verifiable Example:

At the time of writing m5.large instance is not supported on us-east-1e, and that is the subnet returned at index 0 when listing subnets from default VPC in my case.

To better reproduce we can force use of the AZ of second subnet, creating this code:

from dask_cloudprovider.aws.ec2 import EC2Cluster
from dask_cloudprovider.aws.helper import (
    get_default_vpc,
)
from aiobotocore.session import get_session
import botocore

boto_config = botocore.config.Config(retries=dict(max_attempts=10))
region = "us-east-1"
async with get_session().create_client("ec2", region_name=region, config=boto_config) as client:
    vpc = await get_default_vpc(client)
    subnets = (await client.describe_subnets())["Subnets"]
    az = subnets[1]['AvailabilityZone'] # Code at `dask_cloudprovider.aws.ec2` gets subnet at [0], so this will force the issue
    EC2Cluster(
        region="us-east-1",
        availability_zone=az,
        security=False, # Simply to avoid requiring criptography package
        scheduler_instance_type="m5.large",
        worker_instance_type="m5.large",
    )

This outputs:

2024-06-09 14:46:30,639 - distributed.deploy.spec - WARNING - Cluster closed without starting up

And inspecting the stack we can see the following error:

[...]
ClientError: An error occurred (InvalidParameterValue) when calling the RunInstances operation: Value (us-east-1a) for parameter availabilityZone is invalid. Subnet '<REDACTED>' is in the availability zone us-east-1e

During handling of the above exception, another exception occurred:
[...]

Anything else we need to know?:

Changing dask_cloudprovider.aws.helper.get_vpc_subnets to receive and consider the AvailabilityZone should fix the issue. If this makes sense I could open a PR! :)

async def get_vpc_subnets(client, vpc, availability_zone):
    vpcs = (await client.describe_vpcs())["Vpcs"]
    [vpc] = [x for x in vpcs if x["VpcId"] == vpc]
    subnets = (await client.describe_subnets())["Subnets"]
    return [subnet["SubnetId"] for subnet in subnets if subnet["VpcId"] == vpc["VpcId"] and subnet["AvailabilityZone"] == availability_zone]

Environment:

  • Dask version:
    • dask==2024.4.1
    • dask-cloudprovider==2022.10.0
    • distributed==2024.4.1
  • Python version: 3.10.12
  • Operating System: Ubuntu 20.04 LTS (Linux 5.15.146.1-microsoft-standard-WSL2)
  • Install method (conda, pip, source): pip
Lingua principale
Python
Stelle
147
Fork
119
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dask/dask-cloudprovider

Tutte le issue di dask/dask-cloudprovider

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.