Skip to content

Commit

Permalink
Ensure Spec.ProviderID is not empty string
Browse files Browse the repository at this point in the history
If the Spec.ProviderID field is present but an empty string,
we may encounter issues.  This is particularly the case in
DR scenarios when a user is attempting to copy an existing
machine in attempt to create one.
  • Loading branch information
michaelgugino authored and enxebre committed Feb 20, 2020
1 parent 6490dfc commit 1a3ca55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func (a *Actuator) Update(context context.Context, cluster *clusterv1.Cluster, m
// Parent controller should prevent this from ever happening by calling Exists and then Create,
// but instance could be deleted between the two calls.
if existingLen == 0 {
if machine.Spec.ProviderID != nil && (machine.Status.LastUpdated == nil || machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
if machine.Spec.ProviderID != nil && *machine.Spec.ProviderID != "" && (machine.Status.LastUpdated == nil || machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
glog.Infof("%s: Possible eventual-consistency discrepancy; returning an error to requeue", machine.Name)
return &clustererror.RequeueAfterError{RequeueAfter: requeueAfterSeconds * time.Second}
}
Expand Down Expand Up @@ -507,7 +507,7 @@ func (a *Actuator) Describe(cluster *clusterv1.Cluster, machine *machinev1.Machi
return nil, err
}
if len(instances) == 0 {
if machine.Spec.ProviderID != nil && (machine.Status.LastUpdated == nil || machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
if machine.Spec.ProviderID != nil && *machine.Spec.ProviderID != "" && (machine.Status.LastUpdated == nil || machine.Status.LastUpdated.Add(requeueAfterSeconds*time.Second).After(time.Now())) {
glog.Infof("%s: Possible eventual-consistency discrepancy; returning an error to requeue", machine.Name)
return nil, &clustererror.RequeueAfterError{RequeueAfter: requeueAfterSeconds * time.Second}
}
Expand Down

0 comments on commit 1a3ca55

Please sign in to comment.