@@ -835,7 +835,11 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
835835 condition .DeploymentReadyRunningMessage ))
836836 return ctrlResult , nil
837837 }
838- instance .Status .ReadyCount = depl .GetDeployment ().Status .ReadyReplicas
838+
839+ deploy := depl .GetDeployment ()
840+ if deploy .Generation == deploy .Status .ObservedGeneration {
841+ instance .Status .ReadyCount = deploy .Status .ReadyReplicas
842+ }
839843
840844 // verify if network attachment matches expectations
841845 networkReady , networkAttachmentStatus , err := nad .VerifyNetworkStatusFromAnnotation (ctx , helper , instance .Spec .NetworkAttachments , serviceLabels , instance .Status .ReadyCount )
@@ -857,8 +861,20 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
857861 return ctrl.Result {}, err
858862 }
859863
860- if instance .Status .ReadyCount > 0 {
864+ // Mark the Deployment as Ready only if the number of Replicas is equals
865+ // to the Deployed instances (ReadyCount), and the the Status.Replicas
866+ // match Status.ReadyReplicas. If a deployment update is in progress,
867+ // Replicas > ReadyReplicas.
868+ // In addition, make sure the controller sees the last Generation
869+ // by comparing it with the ObservedGeneration.
870+ if deployment .IsReady (deploy ) {
861871 instance .Status .Conditions .MarkTrue (condition .DeploymentReadyCondition , condition .DeploymentReadyMessage )
872+ } else {
873+ instance .Status .Conditions .Set (condition .FalseCondition (
874+ condition .DeploymentReadyCondition ,
875+ condition .RequestedReason ,
876+ condition .SeverityInfo ,
877+ condition .DeploymentReadyRunningMessage ))
862878 }
863879 // create Deployment - end
864880
0 commit comments