Skip to content

Commit e29f08c

Browse files
vflauxNishant Burte
authored andcommitted
Fix AWS Security Group leakage at creation when an error occures (aws-controllers-k8s#174)
fix aws-controllers-k8s/community#1990 Description of changes: Change the hook `security_group/sdk_create_post_set_output.go.tpl` to always return the resource even if an error occurred. At this point the Security Group exists and we should keep track of it. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0c04f83 commit e29f08c

File tree

5 files changed

+12
-27
lines changed

5 files changed

+12
-27
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ack_generate_info:
2-
build_date: "2024-01-15T16:33:37Z"
3-
build_hash: 3753ca3f6610172e9e652d6e5e62e0a05f2e639c
4-
go_version: go1.21.5
5-
version: v0.28.0-11-g3753ca3
2+
build_date: "2024-01-18T10:01:49Z"
3+
build_hash: 7fd3f40fa2160580297ee82914ccdde32312312b
4+
go_version: go1.21.6
5+
version: v0.28.0-17-g7fd3f40
66
api_directory_checksum: 8b27f9e65dbad1f5f825c84d1dbe8fd333baf2a5
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.93

helm/crds/services.k8s.aws_adoptedresources.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ spec:
161161
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
162162
type: string
163163
name:
164-
description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
164+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names'
165165
type: string
166166
uid:
167-
description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
167+
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids'
168168
type: string
169169
required:
170170
- apiVersion

helm/templates/role-writer.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,20 @@ rules:
1010
- ec2.services.k8s.aws
1111
resources:
1212
- dhcpoptions
13-
1413
- elasticipaddresses
15-
1614
- flowlogs
17-
1815
- instances
19-
2016
- internetgateways
21-
2217
- natgateways
23-
2418
- networkacls
25-
2619
- routetables
27-
2820
- securitygroups
29-
3021
- subnets
31-
3222
- transitgateways
33-
3423
- vpcs
35-
3624
- vpcendpoints
37-
3825
- vpcendpointserviceconfigurations
39-
4026
- vpcpeeringconnections
41-
4227
verbs:
4328
- create
4429
- delete

pkg/resource/security_group/sdk.go

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

templates/hooks/security_group/sdk_create_post_set_output.go.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
// Delete the default egress rule
77
if err = rm.deleteDefaultSecurityGroupRule(ctx, &resource{ko}); err != nil {
8-
return nil, err
8+
return &resource{ko}, err
99
}
1010

1111
if err = rm.syncSGRules(ctx, &resource{ko}, nil); err != nil {
12-
return nil, err
12+
return &resource{ko}, err
1313
}
1414

1515
// A ReadOne call for SecurityGroup Rules (NOT SecurityGroups)
1616
// is made to refresh Status.Rules with the recently-updated
1717
// data from the above `sync` call
1818
if rules, err := rm.getRules(ctx, &resource{ko}); err != nil {
19-
return nil, err
19+
return &resource{ko}, err
2020
} else {
2121
ko.Status.Rules = rules
2222
}

0 commit comments

Comments
 (0)