Skip to content

Commit

Permalink
GCP quotas: use proper region-key (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor-S authored Oct 26, 2023
1 parent d8374ac commit 4348fd3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dstack/_internal/core/backends/gcp/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ def get_offers(
quotas[region.name][quota.metric] = quota.limit - quota.usage
offers_with_availability: Dict[Tuple[str, str], InstanceOfferWithAvailability] = {}
for offer in offers:
region = offer.region[:-2] # strip zone
key = (
_unique_instance_name(offer.instance),
offer.region[:-2], # strip zone
region,
)
if key in offers_with_availability:
continue
availability = InstanceAvailability.UNKNOWN
if not _has_gpu_quota(quotas[offer.region], offer.instance.resources):
if not _has_gpu_quota(quotas[region], offer.instance.resources):
availability = InstanceAvailability.NO_QUOTA
# todo quotas: cpu, memory, global gpu

offers_with_availability[key] = InstanceOfferWithAvailability(
**offer.dict(), availability=availability
)
offers_with_availability[key].region = offer.region[:-2] # strip zone
offers_with_availability[key].region = region
return list(offers_with_availability.values())

def terminate_instance(self, instance_id: str, region: str):
Expand Down

0 comments on commit 4348fd3

Please sign in to comment.