@@ -282,7 +282,7 @@ func (r *Reconciler) ensureFinalizer(ctx context.Context, mc *clusterv1beta1.Mem
282282// Condition ReadyToJoin == true means all the above actions have been done successfully at least once.
283283// It will never turn false after true.
284284func (r * Reconciler ) join (ctx context.Context , mc * clusterv1beta1.MemberCluster , imc * clusterv1beta1.InternalMemberCluster ) error {
285- klog .V (2 ).InfoS ("join" , "memberCluster" , klog .KObj (mc ))
285+ klog .V (4 ).InfoS ("join" , "memberCluster" , klog .KObj (mc ))
286286
287287 namespaceName , err := r .syncNamespace (ctx , mc )
288288 if err != nil {
@@ -311,7 +311,7 @@ func (r *Reconciler) join(ctx context.Context, mc *clusterv1beta1.MemberCluster,
311311//
312312// Note that leave doesn't delete any of the resources created by join(). Instead, deleting MemberCluster will delete them.
313313func (r * Reconciler ) leave (ctx context.Context , mc * clusterv1beta1.MemberCluster , imc * clusterv1beta1.InternalMemberCluster ) error {
314- klog .V (2 ).InfoS ("Mark the internal cluster state as `Leave`" , "memberCluster" , klog .KObj (mc ))
314+ klog .V (4 ).InfoS ("Mark the internal cluster state as `Leave`" , "memberCluster" , klog .KObj (mc ))
315315
316316 // Copy spec from member cluster to internal member cluster.
317317 namespaceName := fmt .Sprintf (utils .NamespaceNameFormat , mc .Name )
@@ -324,7 +324,7 @@ func (r *Reconciler) leave(ctx context.Context, mc *clusterv1beta1.MemberCluster
324324
325325// syncNamespace creates or updates the namespace for member cluster.
326326func (r * Reconciler ) syncNamespace (ctx context.Context , mc * clusterv1beta1.MemberCluster ) (string , error ) {
327- klog .V (2 ).InfoS ("Sync the namespace for the member cluster" , "memberCluster" , klog .KObj (mc ))
327+ klog .V (4 ).InfoS ("Sync the namespace for the member cluster" , "memberCluster" , klog .KObj (mc ))
328328 namespaceName := fmt .Sprintf (utils .NamespaceNameFormat , mc .Name )
329329 fleetNamespaceLabelValue := "true"
330330 expectedNS := corev1.Namespace {
@@ -367,7 +367,7 @@ func (r *Reconciler) syncNamespace(ctx context.Context, mc *clusterv1beta1.Membe
367367
368368// syncRole creates or updates the role for member cluster to access its namespace in hub cluster.
369369func (r * Reconciler ) syncRole (ctx context.Context , mc * clusterv1beta1.MemberCluster , namespaceName string ) (string , error ) {
370- klog .V (2 ).InfoS ("Sync the role for the member cluster" , "memberCluster" , klog .KObj (mc ))
370+ klog .V (4 ).InfoS ("Sync the role for the member cluster" , "memberCluster" , klog .KObj (mc ))
371371 // Role name is created using member cluster name.
372372 roleName := fmt .Sprintf (utils .RoleNameFormat , mc .Name )
373373 expectedRole := rbacv1.Role {
@@ -410,7 +410,7 @@ func (r *Reconciler) syncRole(ctx context.Context, mc *clusterv1beta1.MemberClus
410410
411411// syncRoleBinding creates or updates the role binding for member cluster to access its namespace in hub cluster.
412412func (r * Reconciler ) syncRoleBinding (ctx context.Context , mc * clusterv1beta1.MemberCluster , namespaceName string , roleName string ) error {
413- klog .V (2 ).InfoS ("Sync the roleBinding for the member cluster" , "memberCluster" , klog .KObj (mc ))
413+ klog .V (4 ).InfoS ("Sync the roleBinding for the member cluster" , "memberCluster" , klog .KObj (mc ))
414414 // Role binding name is created using member cluster name
415415 roleBindingName := fmt .Sprintf (utils .RoleBindingNameFormat , mc .Name )
416416 expectedRoleBinding := rbacv1.RoleBinding {
@@ -460,7 +460,7 @@ func (r *Reconciler) syncRoleBinding(ctx context.Context, mc *clusterv1beta1.Mem
460460// syncInternalMemberCluster is used to sync spec from MemberCluster to InternalMemberCluster.
461461func (r * Reconciler ) syncInternalMemberCluster (ctx context.Context , mc * clusterv1beta1.MemberCluster ,
462462 namespaceName string , currentImc * clusterv1beta1.InternalMemberCluster ) (* clusterv1beta1.InternalMemberCluster , error ) {
463- klog .V (2 ).InfoS ("Sync internalMemberCluster spec from member cluster" , "memberCluster" , klog .KObj (mc ))
463+ klog .V (4 ).InfoS ("Sync internalMemberCluster spec from member cluster" , "memberCluster" , klog .KObj (mc ))
464464 expectedImc := clusterv1beta1.InternalMemberCluster {
465465 ObjectMeta : metav1.ObjectMeta {
466466 Name : mc .Name ,
@@ -509,7 +509,7 @@ func toOwnerReference(memberCluster *clusterv1beta1.MemberCluster) *metav1.Owner
509509
510510// syncInternalMemberClusterStatus is used to sync status from InternalMemberCluster to MemberCluster & aggregate join conditions from all agents.
511511func (r * Reconciler ) syncInternalMemberClusterStatus (imc * clusterv1beta1.InternalMemberCluster , mc * clusterv1beta1.MemberCluster ) {
512- klog .V (2 ).InfoS ("Sync the internalMemberCluster status" , "memberCluster" , klog .KObj (mc ))
512+ klog .V (4 ).InfoS ("Sync the internalMemberCluster status" , "memberCluster" , klog .KObj (mc ))
513513 if imc == nil {
514514 return
515515 }
@@ -532,7 +532,15 @@ func (r *Reconciler) syncInternalMemberClusterStatus(imc *clusterv1beta1.Interna
532532
533533// updateMemberClusterStatus is used to update member cluster status.
534534func (r * Reconciler ) updateMemberClusterStatus (ctx context.Context , mc * clusterv1beta1.MemberCluster ) error {
535- klog .V (2 ).InfoS ("Update the memberCluster status" , "memberCluster" , klog .KObj (mc ))
535+ joined := condition .IsConditionStatusTrue (meta .FindStatusCondition (mc .Status .Conditions , string (clusterv1beta1 .ConditionTypeMemberClusterJoined )), mc .Generation )
536+ healthy := condition .IsConditionStatusTrue (mc .GetAgentCondition (clusterv1beta1 .MemberAgent , clusterv1beta1 .AgentHealthy ), mc .Generation )
537+ lastReceivedHeartbeat := "nil"
538+ memberAgentStatus := mc .GetAgentStatus (clusterv1beta1 .MemberAgent )
539+ if memberAgentStatus != nil {
540+ lastReceivedHeartbeat = memberAgentStatus .LastReceivedHeartbeat .Format (time .RFC3339 )
541+ }
542+ klog .V (2 ).InfoS ("Update the memberCluster status" , "memberCluster" , klog .KObj (mc ), "joined" , joined , "healthy" , healthy , "lastReceivedHeartbeat" , lastReceivedHeartbeat )
543+
536544 backOffPeriod := retry .DefaultRetry
537545 backOffPeriod .Cap = time .Second * time .Duration (mc .Spec .HeartbeatPeriodSeconds / 2 )
538546
@@ -547,7 +555,7 @@ func (r *Reconciler) updateMemberClusterStatus(ctx context.Context, mc *clusterv
547555
548556// aggregateJoinedCondition is used to calculate and mark the joined or left status for member cluster based on join conditions from all agents.
549557func (r * Reconciler ) aggregateJoinedCondition (mc * clusterv1beta1.MemberCluster ) {
550- klog .V (2 ).InfoS ("Aggregate joined condition from all agents" , "memberCluster" , klog .KObj (mc ))
558+ klog .V (4 ).InfoS ("Aggregate joined condition from all agents" , "memberCluster" , klog .KObj (mc ))
551559 var unknownMessage string
552560 if len (mc .Status .AgentStatus ) < len (r .agents ) {
553561 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 ))
@@ -592,7 +600,7 @@ func (r *Reconciler) aggregateJoinedCondition(mc *clusterv1beta1.MemberCluster)
592600
593601// markMemberClusterReadyToJoin is used to update the ReadyToJoin condition as true of member cluster.
594602func markMemberClusterReadyToJoin (recorder record.EventRecorder , mc apis.ConditionedObj ) {
595- klog .V (2 ).InfoS ("Mark the member cluster ReadyToJoin" , "memberCluster" , klog .KObj (mc ))
603+ klog .V (4 ).InfoS ("Mark the member cluster ReadyToJoin" , "memberCluster" , klog .KObj (mc ))
596604 newCondition := metav1.Condition {
597605 Type : string (clusterv1beta1 .ConditionTypeMemberClusterReadyToJoin ),
598606 Status : metav1 .ConditionTrue ,
@@ -613,7 +621,7 @@ func markMemberClusterReadyToJoin(recorder record.EventRecorder, mc apis.Conditi
613621
614622// markMemberClusterJoined is used to the update the status of the member cluster to have the joined condition.
615623func markMemberClusterJoined (recorder record.EventRecorder , mc apis.ConditionedObj ) {
616- klog .V (2 ).InfoS ("Mark the member cluster joined" , "memberCluster" , klog .KObj (mc ))
624+ klog .V (4 ).InfoS ("Mark the member cluster joined" , "memberCluster" , klog .KObj (mc ))
617625 newCondition := metav1.Condition {
618626 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
619627 Status : metav1 .ConditionTrue ,
@@ -635,7 +643,7 @@ func markMemberClusterJoined(recorder record.EventRecorder, mc apis.ConditionedO
635643
636644// markMemberClusterLeft is used to update the status of the member cluster to have the left condition and mark member cluster as not ready to join.
637645func markMemberClusterLeft (recorder record.EventRecorder , mc apis.ConditionedObj ) {
638- klog .V (2 ).InfoS ("Mark the member cluster left" , "memberCluster" , klog .KObj (mc ))
646+ klog .V (4 ).InfoS ("Mark the member cluster left" , "memberCluster" , klog .KObj (mc ))
639647 newCondition := metav1.Condition {
640648 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
641649 Status : metav1 .ConditionFalse ,
@@ -664,7 +672,7 @@ func markMemberClusterLeft(recorder record.EventRecorder, mc apis.ConditionedObj
664672
665673// markMemberClusterUnknown is used to update the status of the member cluster to have the left condition.
666674func markMemberClusterUnknown (recorder record.EventRecorder , mc apis.ConditionedObj , unknownMessage string ) {
667- klog .V (2 ).InfoS ("Mark the member cluster join condition unknown" , "memberCluster" , klog .KObj (mc ))
675+ klog .V (4 ).InfoS ("Mark the member cluster join condition unknown" , "memberCluster" , klog .KObj (mc ))
668676 newCondition := metav1.Condition {
669677 Type : string (clusterv1beta1 .ConditionTypeMemberClusterJoined ),
670678 Status : metav1 .ConditionUnknown ,
0 commit comments