Skip to content

Commit c702207

Browse files
committed
unnest regions_with_offering logic
1 parent 7dc387b commit c702207

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

sky/clouds/kubernetes.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ def regions_with_offering(cls, instance_type: Optional[str],
232232
if instance_type is None:
233233
return regions
234234

235-
autoscaler_type = kubernetes_utils.get_autoscaler_type()
236235
regions_to_return = []
236+
autoscaler_type = kubernetes_utils.get_autoscaler_type()
237237
for r in regions:
238238
context = r.name
239239
try:
@@ -244,18 +244,20 @@ def regions_with_offering(cls, instance_type: Optional[str],
244244
continue
245245
if fits:
246246
regions_to_return.append(r)
247+
continue
248+
debug_msg = (f'Instance type {instance_type} does '
249+
'not fit in the Kubernetes cluster '
250+
'with context: '
251+
f'{context}. Reason: {reason}')
252+
if autoscaler_type is None:
253+
logger.debug(debug_msg)
254+
continue
255+
autoscaler = kubernetes_utils.get_autoscaler(autoscaler_type)
256+
if autoscaler.can_create_new_instance_of_type(
257+
context, instance_type):
258+
regions_to_return.append(r)
247259
else:
248-
if autoscaler_type is not None:
249-
autoscaler = kubernetes_utils. \
250-
get_autoscaler(autoscaler_type)
251-
if autoscaler.can_create_new_instance_of_type(
252-
context, instance_type):
253-
regions_to_return.append(r)
254-
else:
255-
logger.debug(f'Instance type {instance_type} does '
256-
'not fit in the Kubernetes cluster '
257-
'with context: '
258-
f'{context}. Reason: {reason}')
260+
logger.debug(debug_msg)
259261
return regions_to_return
260262

261263
def instance_type_to_hourly_cost(self,

0 commit comments

Comments
 (0)