@@ -548,8 +548,10 @@ func (r *Reconciler) updateMemberClusterStatus(ctx context.Context, mc *clusterv
548548// aggregateJoinedCondition is used to calculate and mark the joined or left status for member cluster based on join conditions from all agents.
549549func (r * Reconciler ) aggregateJoinedCondition (mc * clusterv1beta1.MemberCluster ) {
550550 klog .V (2 ).InfoS ("Aggregate joined condition from all agents" , "memberCluster" , klog .KObj (mc ))
551+ var unknownMessage string
551552 if len (mc .Status .AgentStatus ) < len (r .agents ) {
552- markMemberClusterUnknown (r .recorder , mc )
553+ unknownMessage = fmt .Sprintf ("Member cluster %s has not reported all the expected agents, expected %d, got %d" , mc .Name , len (r .agents ), len (mc .Status .AgentStatus ))
554+ markMemberClusterUnknown (r .recorder , mc , unknownMessage )
553555 return
554556 }
555557 joined := true
@@ -562,7 +564,8 @@ func (r *Reconciler) aggregateJoinedCondition(mc *clusterv1beta1.MemberCluster)
562564 }
563565 condition := meta .FindStatusCondition (agentStatus .Conditions , string (clusterv1beta1 .AgentJoined ))
564566 if condition == nil {
565- markMemberClusterUnknown (r .recorder , mc )
567+ unknownMessage = fmt .Sprintf ("Member cluster %s has not reported the join condition for agent %s" , mc .Name , agentStatus .Type )
568+ markMemberClusterUnknown (r .recorder , mc , unknownMessage )
566569 return
567570 }
568571
@@ -572,7 +575,8 @@ func (r *Reconciler) aggregateJoinedCondition(mc *clusterv1beta1.MemberCluster)
572575 }
573576
574577 if len (reportedAgents ) < len (r .agents ) {
575- markMemberClusterUnknown (r .recorder , mc )
578+ unknownMessage = fmt .Sprintf ("Member cluster %s has not reported all the expected agents, expected %d, got %d" , mc .Name , len (r .agents ), len (reportedAgents ))
579+ markMemberClusterUnknown (r .recorder , mc , unknownMessage )
576580 return
577581 }
578582
@@ -581,7 +585,8 @@ func (r *Reconciler) aggregateJoinedCondition(mc *clusterv1beta1.MemberCluster)
581585 } else if ! joined && left {
582586 markMemberClusterLeft (r .recorder , mc )
583587 } else {
584- markMemberClusterUnknown (r .recorder , mc )
588+ unknownMessage = "Member agents are not in a consistent state"
589+ markMemberClusterUnknown (r .recorder , mc , unknownMessage )
585590 }
586591}
587592
@@ -592,6 +597,7 @@ func markMemberClusterReadyToJoin(recorder record.EventRecorder, mc apis.Conditi
592597 Type : string (clusterv1beta1 .ConditionTypeMemberClusterReadyToJoin ),
593598 Status : metav1 .ConditionTrue ,
594599 Reason : reasonMemberClusterReadyToJoin ,
600+ Message : "Member cluster is ready to join the fleet" ,
595601 ObservedGeneration : mc .GetGeneration (),
596602 }
597603
@@ -612,6 +618,7 @@ func markMemberClusterJoined(recorder record.EventRecorder, mc apis.ConditionedO
612618 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
613619 Status : metav1 .ConditionTrue ,
614620 Reason : reasonMemberClusterJoined ,
621+ Message : "Member cluster has successfully joined the fleet" ,
615622 ObservedGeneration : mc .GetGeneration (),
616623 }
617624
@@ -633,12 +640,14 @@ func markMemberClusterLeft(recorder record.EventRecorder, mc apis.ConditionedObj
633640 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
634641 Status : metav1 .ConditionFalse ,
635642 Reason : reasonMemberClusterLeft ,
643+ Message : "Member cluster has left the fleet" ,
636644 ObservedGeneration : mc .GetGeneration (),
637645 }
638646 notReadyCondition := metav1.Condition {
639647 Type : string (clusterv1beta1 .ConditionTypeMemberClusterReadyToJoin ),
640648 Status : metav1 .ConditionFalse ,
641649 Reason : reasonMemberClusterNotReadyToJoin ,
650+ Message : "Member cluster is not ready to join the fleet" ,
642651 ObservedGeneration : mc .GetGeneration (),
643652 }
644653
@@ -654,12 +663,13 @@ func markMemberClusterLeft(recorder record.EventRecorder, mc apis.ConditionedObj
654663}
655664
656665// markMemberClusterUnknown is used to update the status of the member cluster to have the left condition.
657- func markMemberClusterUnknown (recorder record.EventRecorder , mc apis.ConditionedObj ) {
666+ func markMemberClusterUnknown (recorder record.EventRecorder , mc apis.ConditionedObj , unknownMessage string ) {
658667 klog .V (2 ).InfoS ("Mark the member cluster join condition unknown" , "memberCluster" , klog .KObj (mc ))
659668 newCondition := metav1.Condition {
660669 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
661670 Status : metav1 .ConditionUnknown ,
662671 Reason : reasonMemberClusterUnknown ,
672+ Message : unknownMessage ,
663673 ObservedGeneration : mc .GetGeneration (),
664674 }
665675
0 commit comments