Skip to content

Commit

Permalink
chore:add log when federated cluster is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-lucky committed Aug 7, 2023
1 parent 0ca60e1 commit b2cf597
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/controllers/federatedcluster/clusterstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit b2cf597

Please sign in to comment.