Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused cleanup flow #411

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading