diff --git a/pkg/controllers/federatedcluster/clusterstatus.go b/pkg/controllers/federatedcluster/clusterstatus.go index f02f6258e..c5a33ef19 100644 --- a/pkg/controllers/federatedcluster/clusterstatus.go +++ b/pkg/controllers/federatedcluster/clusterstatus.go @@ -61,7 +61,7 @@ const ( ClusterNotReachableMsg = "Cluster is not reachable" ) -func collectIndividualClusterStatus( +func (c *FederatedClusterController) collectIndividualClusterStatus( ctx context.Context, cluster *fedcorev1a1.FederatedCluster, fedClient fedclient.Interface, @@ -135,6 +135,13 @@ func collectIndividualClusterStatus( return fmt.Errorf("failed to update cluster status: %w", err) } + switch readyStatus { + case corev1.ConditionFalse: + c.eventRecorder.Eventf(cluster, ClusterHealthzNotOKReason, ClusterHealthzNotOKMessage, "Cluster is not ready") + case corev1.ConditionUnknown: + c.eventRecorder.Eventf(cluster, ClusterNotReachableReason, ClusterNotReachableMsg, "Cluster is not reachable") + } + return nil } @@ -154,6 +161,7 @@ func checkReadyByHealthz( if strings.EqualFold(string(body), "ok") { clusterReadyStatus = corev1.ConditionTrue } else { + logger.V(3).WithValues("body", body).Info("Cluster is not ready") clusterReadyStatus = corev1.ConditionFalse } return corev1.ConditionFalse, clusterReadyStatus