From 3601b3ee837693e255068544aa5cbce936a7923c Mon Sep 17 00:00:00 2001 From: sd-hystax <110374605+sd-hystax@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:09:23 +0300 Subject: [PATCH] OS-7106. Fixed reserved instances recommendation ## 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 --- .../bumiworker/modules/reserved_instances_base.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bumiworker/bumiworker/modules/reserved_instances_base.py b/bumiworker/bumiworker/modules/reserved_instances_base.py index 73f0d9557..b1bedaa15 100644 --- a/bumiworker/bumiworker/modules/reserved_instances_base.py +++ b/bumiworker/bumiworker/modules/reserved_instances_base.py @@ -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 @@ -114,8 +114,12 @@ 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: @@ -123,6 +127,8 @@ def _get(self): 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: