Skip to content

Commit

Permalink
Merge pull request #345 from asmorodskyi/cidr_block
Browse files Browse the repository at this point in the history
VPC cleanup: use DestinationIpv6CidrBlock when available
  • Loading branch information
asmorodskyi authored Jan 30, 2024
2 parents 6c83028 + 1557ff9 commit 8542270
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile_k8s
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
12 changes: 10 additions & 2 deletions ocw/lib/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions requirements_k8s.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ flake8
pytest-cov
pylint
podman~=4.6.0
selenium~=4.12.0
selenium~=4.17.2
2 changes: 1 addition & 1 deletion tests/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions tests/test_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8542270

Please sign in to comment.