Skip to content

Commit

Permalink
OS-7106. Fixed reserved instances recommendation
Browse files Browse the repository at this point in the history
## Description

Fixed Reserved instances module failed when one of offerings was not
found

## Related issue number

OS-7106

## Checklist

* [x] The pull request title is a good summary of the changes
* [ ] Unit tests for the changes exist
* [ ] New and existing unit tests pass locally
  • Loading branch information
sd-hystax authored Dec 7, 2023
1 parent 90c658b commit 3601b3e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bumiworker/bumiworker/modules/reserved_instances_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from collections import OrderedDict
from datetime import datetime, timedelta

from requests import HTTPError
from optscale_client.insider_client.client import Client as InsiderClient

from bumiworker.bumiworker.modules.base import ModuleBase
Expand Down Expand Up @@ -114,15 +114,21 @@ def _get(self):

for offer_key in offer_keys:
params = self._offer_key_to_insider_params(offer_key)
_, offerings = self.insider_cl.find_reserved_instances_offerings(
**params)
try:
_, offerings = self.insider_cl.find_reserved_instances_offerings(
**params)
except HTTPError:
LOG.warning('Offer %s not found' % str(offer_key))
continue
insider_offerings[offer_key] = offerings

for resource_id in resource_id_keys_map:
instance = instance_map[resource_id]
res_flavor_key, res_offer_key = resource_id_keys_map[resource_id]
raw_info = raw_expenses_map[resource_id]
res_insider_offers = insider_offerings.get(res_offer_key)
if not res_insider_offers:
continue
offer_1_monthly_cost, offer_2_monthly_cost = self.get_offers_monthly_costs(
res_insider_offers, instance)
if offer_1_monthly_cost is None or offer_2_monthly_cost is None:
Expand Down

0 comments on commit 3601b3e

Please sign in to comment.