Skip to content

Commit

Permalink
Fixed the ExpireDays error (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma authored Jun 19, 2024
1 parent 9b4476c commit d8975f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cloud_governance/common/mails/postfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def send_email_postfix(self, subject: str, to: any, cc: list, content: str, **kw
if kwargs.get('extra_purse'):
data['extra_purse'] = round(kwargs['extra_purse'], 3)
if self.__es_host:
# self.__es_operations.upload_to_elasticsearch(data=data, index=self.__es_index)
self.__es_operations.upload_to_elasticsearch(data=data, index=self.__es_index)
logger.warn(f'Uploaded to es index: {self.__es_index}')
else:
logger.warn('Error missing the es_host')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone

import pandas
from cloud_governance.common.elasticsearch.elasticsearch_operations import ElasticSearchOperations
Expand Down Expand Up @@ -30,7 +30,7 @@ def __get_es_data(self):
:return:
:rtype:
"""
current_date = (datetime.utcnow().date()).__str__()
current_date = (datetime.now(timezone.utc).date()).__str__()
policy_es_index = self.__environment_variables.get('es_index')
account_name = (self.__environment_variables.get('account', '').upper()
.replace('OPENSHIFT-', '')
Expand Down Expand Up @@ -143,7 +143,10 @@ def __update_delete_days(self, policy_es_data: list):
days = 0
alert_user = True if self.__alert_dry_run else False
dry_run = record.get('DryRun')
days_to_take_action = int(record.get('ExpireDays', self.__days_to_delete_resource))
if record.get('ExpireDays'):
days_to_take_action = int(record.get('ExpireDays'))
else:
days_to_take_action = int(self.__days_to_delete_resource)
if not record.get('SkipPolicy'):
record['SkipPolicy'] = 'NA'
delete_date = ''
Expand Down

0 comments on commit d8975f3

Please sign in to comment.