Skip to content

Commit a4411eb

Browse files
Fix reconciler not detecting differences (#122)
Issue #, if available: aws-controllers-k8s/community#1552 Description of changes: When attempting to debug why conditions were not being set on resources, I discovered that the reconciler was not detecting a difference between the `latest` and `desired` objects' conditions. I determined that this was because `latest.status.conditions` was sharing the same memory as `desired.status.conditions`. Walking through the code with a debugger, I found that it was inside the `Update` code where the memory was being swapped. I have updated these lines in each of the EC2 hook code files so that we no longer return a reference to the `desired` object, and can safely modify the `updated` object independently. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3b1ba70 commit a4411eb

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

pkg/resource/dhcp_options/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (rm *resourceManager) customUpdateDHCPOptions(
3737
// If the `modify` calls (i.e. `sync`) do NOT return
3838
// an error, then the update was successful and desired.Spec
3939
// (now updated.Spec) reflects the latest resource state.
40-
updated = desired
40+
updated = rm.concreteResource(desired.DeepCopy())
4141

4242
if delta.DifferentAt("Spec.Tags") {
4343
if err := rm.syncTags(ctx, desired, latest); err != nil {

pkg/resource/elastic_ip_address/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (rm *resourceManager) customUpdateElasticIP(
3737
// If the `modify` calls (i.e. `sync`) do NOT return
3838
// an error, then the update was successful and desired.Spec
3939
// (now updated.Spec) reflects the latest resource state.
40-
updated = desired
40+
updated = rm.concreteResource(desired.DeepCopy())
4141

4242
if delta.DifferentAt("Spec.Tags") {
4343
if err := rm.syncTags(ctx, desired, latest); err != nil {

pkg/resource/instance/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (rm *resourceManager) customUpdateInstance(
5050
// If the `modify` calls (i.e. `sync`) do NOT return
5151
// an error, then the update was successful and desired.Spec
5252
// (now updated.Spec) reflects the latest resource state.
53-
updated = desired
53+
updated = rm.concreteResource(desired.DeepCopy())
5454

5555
if delta.DifferentAt("Spec.Tags") {
5656
if err := rm.syncTags(ctx, desired, latest); err != nil {

pkg/resource/internet_gateway/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (rm *resourceManager) customUpdateInternetGateway(
3939
// If the `modify` calls (i.e. `sync`) do NOT return
4040
// an error, then the update was successful and desired.Spec
4141
// (now updated.Spec) reflects the latest resource state.
42-
updated = desired
42+
updated = rm.concreteResource(desired.DeepCopy())
4343

4444
if delta.DifferentAt("Spec.VPC") {
4545
if latest.ko.Spec.VPC != nil {

pkg/resource/nat_gateway/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (rm *resourceManager) customUpdateNATGateway(
3737
// If the `modify` calls (i.e. `sync`) do NOT return
3838
// an error, then the update was successful and desired.Spec
3939
// (now updated.Spec) reflects the latest resource state.
40-
updated = desired
40+
updated = rm.concreteResource(desired.DeepCopy())
4141

4242
if delta.DifferentAt("Spec.Tags") {
4343
if err := rm.syncTags(ctx, desired, latest); err != nil {

pkg/resource/route_table/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (rm *resourceManager) customUpdateRouteTable(
196196
// If the `modify` calls (i.e. `sync`) do NOT return
197197
// an error, then the update was successful and desired.Spec
198198
// (now updated.Spec) reflects the latest resource state.
199-
updated = desired
199+
updated = rm.concreteResource(desired.DeepCopy())
200200

201201
if delta.DifferentAt("Spec.Routes") {
202202
if err := rm.syncRoutes(ctx, desired, latest); err != nil {

pkg/resource/security_group/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func (rm *resourceManager) customUpdateSecurityGroup(
421421
// If the `modify` calls (i.e. `sync`) do NOT return
422422
// an error, then the update was successful and desired.Spec
423423
// (now updated.Spec) reflects the latest resource state.
424-
updated = desired
424+
updated = rm.concreteResource(desired.DeepCopy())
425425

426426
if delta.DifferentAt("Spec.IngressRules") || delta.DifferentAt("Spec.EgressRules") {
427427
if err := rm.syncSGRules(ctx, desired, latest); err != nil {

pkg/resource/subnet/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (rm *resourceManager) customUpdateSubnet(
4040
// If the `modify` calls (i.e. `sync`) do NOT return
4141
// an error, then the update was successful and desired.Spec
4242
// (now updated.Spec) reflects the latest resource state.
43-
updated = desired
43+
updated = rm.concreteResource(desired.DeepCopy())
4444

4545
if delta.DifferentAt("Spec.RouteTables") {
4646
if err = rm.updateRouteTableAssociations(ctx, desired, latest, delta); err != nil {

pkg/resource/transit_gateway/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (rm *resourceManager) customUpdateTransitGateway(
3737
// If the `modify` calls (i.e. `sync`) do NOT return
3838
// an error, then the update was successful and desired.Spec
3939
// (now updated.Spec) reflects the latest resource state.
40-
updated = desired
40+
updated = rm.concreteResource(desired.DeepCopy())
4141

4242
if delta.DifferentAt("Spec.Tags") {
4343
if err := rm.syncTags(ctx, desired, latest); err != nil {

pkg/resource/vpc/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (rm *resourceManager) customUpdateVPC(
250250
// If the `modify` calls (i.e. `sync`) do NOT return
251251
// an error, then the update was successful and desired.Spec
252252
// (now updated.Spec) reflects the latest resource state.
253-
updated = desired
253+
updated = rm.concreteResource(desired.DeepCopy())
254254

255255
if delta.DifferentAt("Spec.CIDRBlocks") {
256256
if err := rm.syncCIDRBlocks(ctx, desired, latest); err != nil {

0 commit comments

Comments
 (0)