Skip to content

Commit

Permalink
Fix eventual consistency logic to be consistent
Browse files Browse the repository at this point in the history
Eventual consistency logic is not aligned with
MAO after phases were added.  This is causing
some machines to go failed when they shouldn't.

This commit also removes the error after create
as it is no longer useful.  We manipulate the
machine-object and status, so the next request
will be requeued and our delay attempt is ignored.
  • Loading branch information
michaelgugino authored and alexander-demicev committed Jun 21, 2021
1 parent 1e04754 commit 85f1753
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/actuators/machine/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *Reconciler) create() error {

r.machineScope.setProviderStatus(instance, conditionSuccess())

return r.requeueIfInstancePending(instance)
return nil
}

// delete deletes machine
Expand Down Expand Up @@ -181,7 +181,7 @@ func (r *Reconciler) update() error {

existingLen := len(existingInstances)
if existingLen == 0 {
if r.machine.Spec.ProviderID != nil && *r.machine.Spec.ProviderID != "" && (r.machine.Status.LastUpdated == nil || r.machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
if r.machine.Spec.ProviderID != nil && *r.machine.Spec.ProviderID != "" && len(r.machine.Status.Addresses) == 0 {
klog.Infof("%s: Possible eventual-consistency discrepancy; returning an error to requeue", r.machine.Name)
return &machinecontroller.RequeueAfterError{RequeueAfter: requeueAfterSeconds * time.Second}
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func (r *Reconciler) exists() (bool, error) {
}

if len(existingInstances) == 0 {
if r.machine.Spec.ProviderID != nil && *r.machine.Spec.ProviderID != "" && (r.machine.Status.LastUpdated == nil || r.machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
if r.machine.Spec.ProviderID != nil && *r.machine.Spec.ProviderID != "" && len(r.machine.Status.Addresses) == 0 {
klog.Infof("%s: Possible eventual-consistency discrepancy; returning an error to requeue", r.machine.Name)
return false, &machinecontroller.RequeueAfterError{RequeueAfter: requeueAfterSeconds * time.Second}
}
Expand Down

0 comments on commit 85f1753

Please sign in to comment.