Skip to content

Commit

Permalink
Merge pull request clusterpedia-io#347 from qiuming520/main
Browse files Browse the repository at this point in the history
resolve Cluster Healthy Condition Message isn't empty
  • Loading branch information
Iceber authored Sep 16, 2022
2 parents 4441b06 + d635bec commit 1d69648
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pkg/synchromanager/clustersynchro/cluster_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ func (synchro *ClusterSynchro) checkClusterHealthy() {
}

synchro.startResourceSynchro()
if lastReadyCondition.Status == metav1.ConditionTrue {
// TODO: if lastReadyCondition.Message != "", need process
message := "cluster health responded with ok"
if lastReadyCondition.Status == metav1.ConditionTrue && lastReadyCondition.Message == message {
return
}

if _, err := synchro.dynamicDiscoveryManager.GetAndFetchServerVersion(); err != nil {
message = fmt.Sprintf("cluster health responded with ok, but get server version: %v", err)
}

if lastReadyCondition.Status == metav1.ConditionTrue && lastReadyCondition.Message == message {
// the ready status and message has not been modified,
// to reduce the cluster status updates, do not update the `synchro.healthyCondition`.
return
}

condition := metav1.Condition{
Type: clusterv1alpha2.ClusterHealthyCondition,
Status: metav1.ConditionTrue,
Reason: clusterv1alpha2.ClusterHealthyReason,
Message: "cluster health responded with ok",
Message: message,
LastTransitionTime: metav1.Now().Rfc3339Copy(),
}
defer func() {
synchro.healthyCondition.Store(condition)
}()

if _, err := synchro.dynamicDiscoveryManager.GetAndFetchServerVersion(); err != nil {
condition.Message = fmt.Sprintf("cluster health responded with ok, but get server version: %v", err)
klog.ErrorS(err, "Failed to get cluster version", "cluster", synchro.name)
}
synchro.healthyCondition.Store(condition)
}

// TODO(iceber): resolve for more detailed error
Expand Down

0 comments on commit 1d69648

Please sign in to comment.