Skip to content

Commit

Permalink
Handle state swaps with care
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Olshevski committed Dec 29, 2023
1 parent 85ad2d5 commit 6d43d4d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/controllers/synthesis/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *podLifecycleController) shouldDeletePod(logger logr.Logger, comp *apiv1
return logger, &pod, true
}

// TODO: Is it necessary to allow concurrent pods while one is terminating to avoid deadlocks?
// TODO: Allow a second concurrent pod only while one is terminating (to avoid deadlocks)

// Synthesis is done
if comp.Status.CurrentState != nil && comp.Status.CurrentState.Synthesized {
Expand Down Expand Up @@ -151,8 +151,10 @@ func (c *podLifecycleController) shouldDeletePod(logger logr.Logger, comp *apiv1
}

func swapStates(syn *apiv1.Synthesizer, comp *apiv1.Composition) {
// TODO: Is there ever a case where we would _not_ want to swap current->prev? Such as if prev succeeded but cur hasn't?
comp.Status.PreviousState = comp.Status.CurrentState
// If the previous state has been synthesized but not the current, keep the previous to avoid orphaning deleted resources
if comp.Status.CurrentState != nil && comp.Status.CurrentState.Synthesized {
comp.Status.PreviousState = comp.Status.CurrentState
}
comp.Status.CurrentState = &apiv1.Synthesis{
ObservedCompositionGeneration: comp.Generation,
}
Expand Down

0 comments on commit 6d43d4d

Please sign in to comment.