Skip to content

Commit

Permalink
Remove unused cleanup flow
Browse files Browse the repository at this point in the history
We not using listing of EKS clusters anymore for years
because we stop running tests which creating clusters.
So this logic is orphaned and can/should be dropped
  • Loading branch information
asmorodskyi committed Oct 18, 2024
1 parent eee9ee0 commit d346477
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
16 changes: 1 addition & 15 deletions ocw/lib/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from ocw.lib.azure import Azure
from ocw.lib.ec2 import EC2
from ocw.lib.gce import GCE
from ocw.lib.eks import EKS
from ocw.lib.emailnotify import send_mail, send_cluster_notification
from ocw.lib.emailnotify import send_mail
from ocw.enums import ProviderChoice

logger = logging.getLogger(__name__)
Expand All @@ -28,16 +27,3 @@ def cleanup_run():
except Exception as ex:
logger.exception("[%s] Cleanup failed!", namespace)
send_mail(f'{type(ex).__name__} on Cleanup in [{namespace}]', traceback.format_exc())


def list_clusters():
for namespace in PCWConfig.get_namespaces_for('clusters'):
try:
clusters = EKS(namespace).all_clusters()
quantity = sum(len(clusters[c1]) for c1 in clusters)
logger.info("%d cluster(s) found", quantity)
if quantity > 0:
send_cluster_notification(namespace, clusters)
except Exception as ex:
logger.exception("[%s] List clusters failed!", namespace)
send_mail(f'{type(ex).__name__} on List clusters in [{namespace}]', traceback.format_exc())
11 changes: 0 additions & 11 deletions ocw/lib/emailnotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ def draw_instance_table(objects):
return table.draw()


def send_cluster_notification(namespace, clusters):
if len(clusters) and PCWConfig.has('notify'):
clusters_str = ''
for region in clusters:
clusters_list = ' '.join([str(cluster) for cluster in clusters[region]])
clusters_str = f'{clusters_str}\n{region} : {clusters_list}'
logger.debug("Full clusters list - %s", clusters_str)
send_mail(f"[{namespace}] EC2 clusters found", clusters_str,
receiver_email=PCWConfig.get_feature_property('notify', 'to', namespace))


def send_mail(subject, message, receiver_email=None):
if PCWConfig.has('notify'):
smtp_server = PCWConfig.get_feature_property('notify', 'smtp')
Expand Down
1 change: 0 additions & 1 deletion webui/PCWConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def get_feature_property(feature: str, feature_property: str, namespace: str | N
'updaterun/default_ttl': {'default': 44400, 'return_type': int},
'notify/to': {'default': None, 'return_type': str},
'notify/age-hours': {'default': 12, 'return_type': int},
'cluster.notify/to': {'default': None, 'return_type': str},
'notify/smtp': {'default': None, 'return_type': str},
'notify/smtp-port': {'default': 25, 'return_type': int},
'notify/from': {'default': '[email protected]', 'return_type': str},
Expand Down

0 comments on commit d346477

Please sign in to comment.