address race condition in fog
@@ -132,10 +132,22 @@ func (r *AzureSqlFailoverGroupReconciler) Reconcile(req ctrl.Request) (ctrl.Resu
return ctrl.Result{}, nil
}
+ _, err := r.AzureSqlFailoverGroupManager.GetFailoverGroup(ctx, instance.Spec.ResourceGroup, instance.Spec.Server, instance.GetName())
+ if err != nil {
+ if azerr := errhelp.NewAzureErrorAzureError(err); azerr.Type == errhelp.ResourceNotFound {
+ log.Info("waiting for failovergroup to come up")
+ return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
+ }
+ return ctrl.Result{}, err
+ }
+
r.Recorder.Event(&instance, v1.EventTypeNormal, "Provisioned", "AzureSqlFailoverGroup "+instance.ObjectMeta.Name+" provisioned ")
msg := fmt.Sprintf("AzureSqlFailoverGroup %s successfully provisioned", instance.ObjectMeta.Name)
log.Info(msg)
instance.Status.Message = msg
+ instance.Status.State = "done"
+ instance.Status.Provisioning = false
+ instance.Status.Provisioned = true
return ctrl.Result{}, nil
}
@@ -209,6 +221,8 @@ func (r *AzureSqlFailoverGroupReconciler) reconcileExternal(ctx context.Context,
return errhelp.NewAzureError(err)
}
+ instance.Status.Provisioning = true
+
_, err = r.AzureSqlFailoverGroupManager.GetFailoverGroup(ctx, groupName, servername, failoverGroupName)
if err != nil {
return errhelp.NewAzureError(err)
