From 80d3a4325b4d5defedab93e57c4d81be448db352 Mon Sep 17 00:00:00 2001 From: Anton Smorodskyi Date: Mon, 29 Jan 2024 15:10:19 +0100 Subject: [PATCH 1/3] VPC cleanup: use DestinationIpv6CidrBlock when available --- ocw/lib/ec2.py | 12 ++++++++++-- tests/test_ec2.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ocw/lib/ec2.py b/ocw/lib/ec2.py index a14b258b..dab2b383 100644 --- a/ocw/lib/ec2.py +++ b/ocw/lib/ec2.py @@ -253,10 +253,18 @@ def delete_routing_tables(self, region: str, vpc_id: str) -> None: if self.dry_run: self.log_info(f"{route_table['RouteTableId']} route will not be deleted due to dry_run mode") self.log_dbg(route) - else: + elif 'DestinationCidrBlock' in route: + self.log_info(f"Delete route {route_table['RouteTableId']}") + self.log_dbg(route) + self.ec2_client(region).delete_route(RouteTableId=route_table['RouteTableId'], + DestinationCidrBlock=route['DestinationCidrBlock']) + elif 'DestinationIpv6CidrBlock' in route: self.log_info(f"Delete route {route_table['RouteTableId']}") self.log_dbg(route) - self.ec2_client(region).delete_route(RouteTableId=route_table['RouteTableId']) + self.ec2_client(region).delete_route(RouteTableId=route_table['RouteTableId'], + DestinationIpv6CidrBlock=route['DestinationIpv6CidrBlock']) + else: + raise RuntimeError(f'Failed to delete {route}') if route_table['Associations'] == []: if self.dry_run: self.log_info(f"{route_table['RouteTableId']} routing table will not be deleted due to dry_run mode") diff --git a/tests/test_ec2.py b/tests/test_ec2.py index c401b09e..34f4fe41 100644 --- a/tests/test_ec2.py +++ b/tests/test_ec2.py @@ -170,7 +170,7 @@ def disassociate_route_table(self, AssociationId): def describe_route_tables(self, Filters): return MockedEC2Client.routing_tables - def delete_route(self, RouteTableId): + def delete_route(self, RouteTableId, DestinationCidrBlock=None, DestinationIpv6CidrBlock=None): if RouteTableId == '2': MockedEC2Client.delete_route_called = True From 1dd30d118bcf877a719e093252fc865f35a27b1e Mon Sep 17 00:00:00 2001 From: Anton Smorodskyi Date: Mon, 29 Jan 2024 16:49:28 +0100 Subject: [PATCH 2/3] Switch to pip azure-cli install because azure-cli rpm not support python3.11 --- Dockerfile_k8s | 2 +- requirements.txt | 8 ++++---- requirements_k8s.txt | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile_k8s b/Dockerfile_k8s index 8c51c754..93694f6d 100644 --- a/Dockerfile_k8s +++ b/Dockerfile_k8s @@ -1,6 +1,6 @@ FROM registry.suse.com/bci/python:3.11 -RUN zypper -n in gcc tar gzip kubernetes1.24-client aws-cli azure-cli && zypper clean && rm -rf /var/cache +RUN zypper -n in gcc tar gzip kubernetes1.24-client aws-cli && zypper clean && rm -rf /var/cache # Google cli installation RUN curl -sf https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-415.0.0-linux-x86_64.tar.gz | tar -zxf - -C /opt \ diff --git a/requirements.txt b/requirements.txt index b671bbf7..80b93259 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ boto3 -azure-mgmt-compute==30.1.0 +azure-mgmt-compute==30.4.0 azure-mgmt-storage==21.1.0 -azure-mgmt-resource==23.0.1 -azure-storage-blob==12.17.0 -azure-identity==1.14.0 +azure-mgmt-resource==23.1.0b2 +azure-storage-blob==12.19.0 +azure-identity==1.14.1 cachetools msrestazure==0.6.4 uwsgi==2.0.22 diff --git a/requirements_k8s.txt b/requirements_k8s.txt index 34435c8a..0589fe09 100644 --- a/requirements_k8s.txt +++ b/requirements_k8s.txt @@ -1,7 +1,8 @@ oauth2client kubernetes +azure-cli==2.56.0 google-api-python-client==2.96.0 -azure-mgmt-containerservice==22.0.0 -azure-identity==1.14.0 -azure-mgmt-resource==23.0.1 +azure-mgmt-containerservice==28.0.0 +azure-identity==1.14.1 +azure-mgmt-resource==23.1.0b2 boto3 From 1557ff9fa9f851379daf6e43697682142e603b86 Mon Sep 17 00:00:00 2001 From: Anton Smorodskyi Date: Mon, 29 Jan 2024 22:15:07 +0100 Subject: [PATCH 3/3] Upgrade selenium to fix pytest.PytestUnraisableExceptionWarning --- requirements_test.txt | 2 +- tests/test_webui.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/requirements_test.txt b/requirements_test.txt index c11059f9..ec377210 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -7,4 +7,4 @@ flake8 pytest-cov pylint podman~=4.6.0 -selenium~=4.12.0 +selenium~=4.17.2 diff --git a/tests/test_webui.py b/tests/test_webui.py index 2228bac7..c80b5cef 100644 --- a/tests/test_webui.py +++ b/tests/test_webui.py @@ -12,12 +12,6 @@ from selenium.webdriver import firefox from selenium.webdriver.common.by import By -# This can be dropped when Selenium switches to no longer write to geckodriver.log -import warnings -# Ignore ResourceWarning messages that can happen at random when closing resources: -# Exception ignored in: <_io.FileIO name='/dev/null' mode='wb' closefd=True> -warnings.filterwarnings(action="ignore", message="unclosed", category=ResourceWarning) - USERNAME = "username" PASSWORD = "password"