Skip to content

Commit

Permalink
Merge pull request #411 from SUSE/drop_list_clusters
Browse files Browse the repository at this point in the history
Remove unused cleanup flow
  • Loading branch information
asmorodskyi authored Oct 18, 2024
2 parents eee9ee0 + d346477 commit 9a35218
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': 'pcw@publiccloud.qa.suse.de', 'return_type': str},
Expand Down

0 comments on commit 9a35218

Please sign in to comment.