-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
f0d1062 OS-7579. Updaded README file in order to use Python 3.9 during cluste… (#809) 6559239 OS-7575. RI/SP breakdown performance improvement 3fa1885 OS-7507. nebius_migration archive 7ebcb54 OS-7578. Handle missing AttachedInstanceId for Alibaba cloud
- Loading branch information
Showing
10 changed files
with
117 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from collections import defaultdict | ||
|
||
from bumiworker.bumiworker.consts import ArchiveReason | ||
from bumiworker.bumiworker.modules.base import ArchiveBase | ||
from bumiworker.bumiworker.modules.recommendations.nebius_migration import ( | ||
NebiusMigration as NebiusMigrationRecommendation | ||
) | ||
|
||
|
||
class NebiusMigration(ArchiveBase, NebiusMigrationRecommendation): | ||
|
||
@property | ||
def supported_cloud_types(self): | ||
return list(self.get_cloud_funcs_map().keys()) | ||
|
||
def _get(self, previous_options, optimizations, cloud_accounts_map, | ||
**kwargs): | ||
result = [] | ||
if not self._is_nebius_option_enabled(): | ||
return result | ||
|
||
account_optimizations_map = defaultdict(list) | ||
for optimization in optimizations: | ||
account_optimizations_map[optimization['cloud_account_id']].append( | ||
optimization) | ||
|
||
for cloud_account_id, optimizations_ in account_optimizations_map.items(): | ||
reason = ArchiveReason.OPTIONS_CHANGED if ( | ||
cloud_account_id in cloud_accounts_map | ||
) else ArchiveReason.CLOUD_ACCOUNT_DELETED | ||
for optimization in optimizations_: | ||
self._set_reason_properties(optimization, reason) | ||
result.append(optimization) | ||
return result | ||
|
||
|
||
def main(organization_id, config_client, created_at, **kwargs): | ||
return NebiusMigration( | ||
organization_id, config_client, created_at).get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
diworker/diworker/migrations/2024052311450000_added_aws_lineitemtype_index.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import logging | ||
from diworker.diworker.migrations.base import BaseMigration | ||
|
||
""" | ||
Added aws LineItemType index | ||
""" | ||
|
||
LOG = logging.getLogger(__name__) | ||
NEW_INDEXES = { | ||
'AWSLineItemType': ( | ||
['cloud_account_id', 'lineItem/LineItemType', 'start_date'], | ||
{'lineItem/LineItemType': {'$exists': True}} | ||
) | ||
} | ||
|
||
|
||
class Migration(BaseMigration): | ||
@property | ||
def raw_collection(self): | ||
return self.db.raw_expenses | ||
|
||
def _get_existing_index_names(self): | ||
return [i['name'] for i in self.raw_collection.list_indexes()] | ||
|
||
def upgrade(self): | ||
existing_indexes = self._get_existing_index_names() | ||
for index_name, (index_keys, partial_exp) in NEW_INDEXES.items(): | ||
if index_name in existing_indexes: | ||
continue | ||
self.raw_collection.create_index( | ||
[(f, 1) for f in index_keys], | ||
name=index_name, | ||
background=True, | ||
partialFilterExpression=partial_exp) | ||
|
||
def downgrade(self): | ||
existing_indexes = self._get_existing_index_names() | ||
for index_name in NEW_INDEXES.keys(): | ||
if index_name in existing_indexes: | ||
self.raw_collection.drop_index(index_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters