@@ -659,26 +659,31 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
659659 return ctrlResult , nil
660660 }
661661
662+ // create Statefulset - end
663+ // Handle service init
664+ ctrlResult , err = r .reconcileServices (ctx , instance , helper , serviceLabels , serviceName )
665+ if err != nil {
666+ instance .Status .Conditions .Set (condition .FalseCondition (
667+ condition .ExposeServiceReadyCondition ,
668+ condition .ErrorReason ,
669+ condition .SeverityWarning ,
670+ condition .ExposeServiceReadyErrorMessage ,
671+ err .Error ()))
672+ return ctrlResult , err
673+ } else if (ctrlResult != ctrl.Result {}) {
674+ instance .Status .Conditions .Set (condition .FalseCondition (
675+ condition .ExposeServiceReadyCondition ,
676+ condition .RequestedReason ,
677+ condition .SeverityInfo ,
678+ condition .ExposeServiceReadyRunningMessage ))
679+ return ctrlResult , err
680+ }
681+
662682 stateful := sfset .GetStatefulSet ()
663683 if stateful .Generation == stateful .Status .ObservedGeneration {
664684 instance .Status .ReadyCount = stateful .Status .ReadyReplicas
665685 }
666686
667- // Only run runtime config when all pods are ready and no rolling update in progress
668- if instance .Status .ReadyCount == * instance .Spec .Replicas &&
669- stateful .Status .UpdatedReplicas == * instance .Spec .Replicas {
670- err = r .reconcileRuntimeConfig (ctx , helper , instance , serviceLabels , serviceName )
671- if err != nil {
672- instance .Status .Conditions .Set (condition .FalseCondition (
673- condition .ServiceConfigReadyCondition ,
674- condition .ErrorReason ,
675- condition .SeverityWarning ,
676- condition .ServiceConfigReadyErrorMessage ,
677- err .Error ()))
678- return ctrl.Result {}, err
679- }
680- }
681-
682687 // verify if network attachment matches expectations
683688 networkReady , networkAttachmentStatus , err := nad .VerifyNetworkStatusFromAnnotation (ctx , helper , networkAttachments , serviceLabels , instance .Status .ReadyCount )
684689 if err != nil {
@@ -700,26 +705,6 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
700705 return ctrlResult , nil
701706 }
702707
703- // create Statefulset - end
704- // Handle service init
705- ctrlResult , err = r .reconcileServices (ctx , instance , helper , serviceLabels , serviceName )
706- if err != nil {
707- instance .Status .Conditions .Set (condition .FalseCondition (
708- condition .ExposeServiceReadyCondition ,
709- condition .ErrorReason ,
710- condition .SeverityWarning ,
711- condition .ExposeServiceReadyErrorMessage ,
712- err .Error ()))
713- return ctrlResult , err
714- } else if (ctrlResult != ctrl.Result {}) {
715- instance .Status .Conditions .Set (condition .FalseCondition (
716- condition .ExposeServiceReadyCondition ,
717- condition .RequestedReason ,
718- condition .SeverityInfo ,
719- condition .ExposeServiceReadyRunningMessage ))
720- return ctrlResult , err
721- }
722-
723708 svcList , err := service .GetServicesListWithLabel (
724709 ctx ,
725710 helper ,
@@ -736,6 +721,21 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
736721 return ctrl.Result {}, err
737722 }
738723
724+ // Only run runtime config when all pods are ready and no rolling update in progress
725+ if instance .Status .ReadyCount == * instance .Spec .Replicas &&
726+ stateful .Status .UpdatedReplicas == * instance .Spec .Replicas {
727+ err = r .reconcileRuntimeConfig (ctx , helper , instance , serviceLabels , serviceName )
728+ if err != nil {
729+ instance .Status .Conditions .Set (condition .FalseCondition (
730+ condition .ServiceConfigReadyCondition ,
731+ condition .ErrorReason ,
732+ condition .SeverityWarning ,
733+ condition .ServiceConfigReadyErrorMessage ,
734+ err .Error ()))
735+ return ctrl.Result {}, err
736+ }
737+ }
738+
739739 if statefulset .IsReady (stateful ) && len (svcList .Items ) > 0 {
740740 instance .Status .Conditions .MarkTrue (condition .DeploymentReadyCondition , condition .DeploymentReadyMessage )
741741 instance .Status .Conditions .MarkTrue (condition .ExposeServiceReadyCondition , condition .ExposeServiceReadyMessage )
@@ -797,7 +797,9 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
797797 return ctrl.Result {}, nil
798798}
799799
800- func getPodIPInNetwork (ovnPod corev1.Pod , namespace string , networkAttachment string ) (string , error ) {
800+ func getPodIPInNetwork (ovnPod corev1.Pod , instance * ovnv1.OVNDBCluster ) (string , error ) {
801+ namespace := instance .Namespace
802+ networkAttachment := instance .Spec .NetworkAttachment
801803 netStat , err := nad .GetNetworkStatusFromAnnotation (ovnPod .Annotations )
802804 if err != nil {
803805 err = fmt .Errorf ("error while getting the Network Status for pod %s: %w" , ovnPod .Name , err )
@@ -812,6 +814,12 @@ func getPodIPInNetwork(ovnPod corev1.Pod, namespace string, networkAttachment st
812814 }
813815 // If this is reached it means that no IP was found, construct error and return
814816 err = fmt .Errorf ("%w IP address from pod %s in network %s, IP is empty" , util .ErrInvalidStatus , ovnPod .Name , networkAttachment )
817+ instance .Status .Conditions .Set (condition .FalseCondition (
818+ condition .NetworkAttachmentsReadyCondition ,
819+ condition .ErrorReason ,
820+ condition .SeverityWarning ,
821+ condition .NetworkAttachmentsReadyErrorMessage ,
822+ err .Error ()))
815823 return "" , err
816824}
817825
@@ -1005,11 +1013,11 @@ func (r *OVNDBClusterReconciler) reconcileServices(
10051013 return ctrl.Result {}, err
10061014 }
10071015
1008- dnsIP , err := getPodIPInNetwork (ovnPod , instance .Namespace , instance .Spec .NetworkAttachment )
1009- dnsIPsList = append (dnsIPsList , dnsIP )
1016+ dnsIP , err := getPodIPInNetwork (ovnPod , instance )
10101017 if err != nil {
10111018 return ctrl.Result {}, err
10121019 }
1020+ dnsIPsList = append (dnsIPsList , dnsIP )
10131021 }
10141022 // DNSData info is called every reconcile loop to ensure that even if a pod gets
10151023 // restarted and it's IP has changed, the DNSData CR will have the correct info.
0 commit comments