Skip to content

Commit

Permalink
bugfix for #65: do not add resource maxima when quota is < 1 (#67)
Browse files Browse the repository at this point in the history
This addresses an error where we specify resource maxima for GKE clusters using quota information returned from the GCP compute API. The API can return a quota of zero for a given resource type, but requesting a limit of zero in the cluster creation API causes an error, so this change prevents setting a limit of zero for any resource.
  • Loading branch information
ajslone authored Aug 2, 2020
1 parent af9dd99 commit 7c75f38
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions caliban/platform/gke/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,19 @@ def resource_limits_from_quotas(

for q in quotas:
metric = q['metric']
limit = q['limit']
limit = int(q['limit'])

# the api can return a limit of 0, but specifying a limit of zero
# causes an error when configuring the cluster, so we skip any
# resources with no quota
if limit < 1:
continue

if metric == 'CPUS':
limits.append({'resourceType': 'cpu', 'maximum': str(limit)})
limits.append({
'resourceType': 'memory',
'maximum': str(int(limit) * k.MAX_GB_PER_CPU)
'maximum': str(limit * k.MAX_GB_PER_CPU)
})
continue

Expand Down

0 comments on commit 7c75f38

Please sign in to comment.