Skip to content

Commit

Permalink
Call ReadOne as part of createResource (#43)
Browse files Browse the repository at this point in the history
Some status fields were not being set properly during the first reconciliation loop, as part of the Create flow. This loop called the `Create*` operation, and set any status fields that are returned as part of the output shape, and then returned successfully (without re-queuing). Previously, the reconciler would loop again to describe and set the other status fields, however we now filter out any events that do not change the resource generation. 

This fix will call `ReadOne` to describe the newly created resource and set the status fields based on that response, directly after calling `Create*`. This ensures all fields are set before completing the first reconciliation loop.
  • Loading branch information
RedbackThomson authored Aug 10, 2021
1 parent d7b6e45 commit 9a99433
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/runtime/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ func (r *resourceReconciler) createResource(
if err != nil {
return latest, err
}

rlog.Enter("rm.ReadOne")
observed, err := rm.ReadOne(ctx, latest)
rlog.Exit("rm.ReadOne", err)
if err != nil {
return latest, err
}

// Take the status from the latest ReadOne
latest.SetStatus(observed)

// Ensure that we are patching any changes to the annotations/metadata and
// the Spec that may have been set by the resource manager's successful
// Create call above.
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/aws_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ type AWSResource interface {
// SetIdentifiers will set the the Spec or Status field that represents the
// identifier for the resource.
SetIdentifiers(*ackv1alpha1.AWSIdentifiers) error
// SetStatus will set the Status field for the resource
SetStatus(AWSResource)
}

0 comments on commit 9a99433

Please sign in to comment.