Skip to content

Commit

Permalink
Refactor same thing from the calling side
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Olshevski committed Jan 5, 2024
1 parent 542abc5 commit 8bee479
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 1 addition & 6 deletions internal/controllers/reconciliation/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ func (c *Controller) Reconcile(ctx context.Context, req *reconstitution.Request)
}

// Find the current and (optionally) previous desired states in the cache
currentGen := comp.Status.CurrentState.ObservedCompositionGeneration
if comp.DeletionTimestamp != nil {
// TODO
currentGen++
}
resource, exists := c.resourceClient.Get(ctx, &req.ResourceRef, currentGen)
resource, exists := c.resourceClient.Get(ctx, &req.ResourceRef, reconstitution.GetCompositionGenerationAtCurrentState(comp))
if !exists {
// It's possible for the cache to be empty because a manifest for this resource no longer exists at the requested composition generation.
// Dropping the work item is safe since filling the new version will generate a new queue message.
Expand Down
7 changes: 7 additions & 0 deletions internal/reconstitution/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,10 @@ func getCompositionGeneration(comp *apiv1.Composition, syn *apiv1.Synthesis) int
}
return syn.ObservedCompositionGeneration
}

func GetCompositionGenerationAtCurrentState(comp *apiv1.Composition) int64 {
if comp.Status.CurrentState == nil {
return 0
}
return getCompositionGeneration(comp, comp.Status.CurrentState)
}

0 comments on commit 8bee479

Please sign in to comment.