Skip to content

Commit 0efa43f

Browse files
Fix Internet Gateway terminal codes (#68)
Issue #, if available: [1362](aws-controllers-k8s/community#1362) Description of changes: - Removed `InvalidVpcId.Malformed` error from terminal codes for **Internet Gateway** resource. - Removed Integration tests for the `InvalidVpcId.Malformed` terminal code. Initially, I thought `InvalidVpcId.Malformed` should be included in the terminal codes. Later, observed that Internet Gateway resource being created after adding the integration tests for the malformed vpc id terminal code. This is expected as per our code because initially the resource will be created with no vpc attachment and later if we pass VPC ID, it will be attached to the resource. After discussions and local testing I observed that if you add malformed VPC ID it will create a resource and if you try to update the VPC ID to a valid one, it will create a new resource and leave the initial one in dangling state that cannot be deleted, so we decided not to include malformed VPC ID for Internet Gateway resource. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 70316cc commit 0efa43f

File tree

5 files changed

+5
-54
lines changed

5 files changed

+5
-54
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-08-02T21:22:57Z"
2+
build_date: "2022-08-08T17:04:17Z"
33
build_hash: 87477ae8ca8ac6ddb8c565bbd910cc7e30f55ed0
44
go_version: go1.18.3
55
version: v0.19.3
66
api_directory_checksum: 8c35bdcab21768638dfaa277896e05fdd8a11969
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: adb5f55a4d7edff7d658a208d5ae3bf6d86f3172
10+
file_checksum: da927f39a013c7d5ed82db3df0daf4cd22c605d3
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ resources:
236236
sdk_read_many_post_build_request:
237237
template_path: hooks/elastic_ip_address/sdk_read_many_post_build_request.go.tpl
238238
InternetGateway:
239-
exceptions:
240-
terminal_codes:
241-
- InvalidVpcId.Malformed
242239
fields:
243240
Tags:
244241
from:

generator.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ resources:
236236
sdk_read_many_post_build_request:
237237
template_path: hooks/elastic_ip_address/sdk_read_many_post_build_request.go.tpl
238238
InternetGateway:
239-
exceptions:
240-
terminal_codes:
241-
- InvalidVpcId.Malformed
242239
fields:
243240
Tags:
244241
from:

pkg/resource/internet_gateway/sdk.go

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/tests/test_internet_gateway.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -181,36 +181,4 @@ def test_vpc_association(self, ec2_client, empty_vpc):
181181
time.sleep(DELETE_WAIT_AFTER_SECONDS)
182182

183183
# Check Internet Gateway no longer exists in AWS
184-
ec2_validator.assert_internet_gateway(resource_id, exists=False)
185-
186-
def test_terminal_condition_malformed_vpc(self):
187-
test_resource_values = REPLACEMENT_VALUES.copy()
188-
resource_name = random_suffix_name("ig-ack-fail-1", 24)
189-
test_resource_values["INTERNET_GATEWAY_NAME"] = resource_name
190-
test_resource_values["VPC_ID"] = "MalformedVpcId"
191-
192-
# Load Internet Gateway CR
193-
resource_data = load_ec2_resource(
194-
"internet_gateway_vpc_attachment",
195-
additional_replacements=test_resource_values,
196-
)
197-
logging.debug(resource_data)
198-
199-
# Create k8s resource
200-
ref = k8s.CustomResourceReference(
201-
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
202-
resource_name, namespace="default",
203-
)
204-
k8s.create_custom_resource(ref, resource_data)
205-
cr = k8s.wait_resource_consumed_by_controller(ref)
206-
207-
assert cr is not None
208-
assert k8s.get_resource_exists(ref)
209-
210-
expected_msg = 'InvalidVpcId.Malformed: Invalid id: "MalformedVpcId"'
211-
terminal_condition = k8s.get_resource_condition(ref, "ACK.Terminal")
212-
# Example condition message:
213-
# An error occurred (InvalidVpcId.Malformed) when calling the AttachInternetGateway operation:
214-
# Invalid id: "MalformedVpcId"
215-
# (expecting "vpc-...")
216-
assert expected_msg in terminal_condition['message']
184+
ec2_validator.assert_internet_gateway(resource_id, exists=False)

0 commit comments

Comments
 (0)