Skip to content

Commit

Permalink
Mute common error when deleting VPC
Browse files Browse the repository at this point in the history
  • Loading branch information
asmorodskyi committed Sep 17, 2024
1 parent 684a131 commit b3ec48c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion ocw/lib/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@ def vpc_can_be_deleted(self, resource_vpc, vpc_id) -> bool:

def report_cleanup_results(self, vpc_errors: list, vpc_notify: list, vpc_locked: list) -> None:
if len(vpc_errors) > 0:
send_mail(f'Errors on VPC deletion in [{self._namespace}]', '\n'.join(vpc_errors))
# this is most common error message which we can not fix.
# So no point to spam us with notifications about it
known_error = "An error occurred (DependencyViolation) when calling the DeleteVpc operation"
filtered = [x for x in vpc_errors if known_error not in x]
if len(filtered) > 0:
send_mail(f'Errors on VPC deletion in [{self._namespace}]', '\n'.join(vpc_errors))
if len(vpc_notify) > 0:
send_mail(f'{len(vpc_notify)} VPC\'s should be deleted, skipping due vpc-notify-only=True', ','.join(vpc_notify))
if len(vpc_locked) > 0:
Expand Down
2 changes: 0 additions & 2 deletions ocw/lib/emailnotify.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from datetime import timedelta
import smtplib
import logging
from email.mime.text import MIMEText
from texttable import Texttable
from django.urls import reverse
from webui.PCWConfig import PCWConfig
from webui.settings import build_absolute_uri
from ..models import Instance

logger = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions ocw/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def render(self, record):
link['url'], link['title'], link['title'], static('img/openqa.svg'))
return ""


class TagsColumn(tables.TemplateColumn):

def __init__(self, template_name=None, **extra):
Expand Down
1 change: 0 additions & 1 deletion tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def mocked__update_provider(arg1, arg2, arg3):
def mocked_auto_delete_instances():
call_stack.append('auto_delete_instances')


monkeypatch.setattr('ocw.lib.db._update_provider', mocked__update_provider)
monkeypatch.setattr('ocw.lib.db.auto_delete_instances', mocked_auto_delete_instances)

Expand Down

0 comments on commit b3ec48c

Please sign in to comment.