Merge pull request #597 from wawa0210/fix-repeat-get-cluster-status
Delete the extra getClusterHealthStatus logic and use the wait.Poll framework directly
This commit is contained in:
commit
3bbf63dc87
|
@ -131,26 +131,22 @@ func (c *ClusterStatusController) syncClusterStatus(cluster *v1alpha1.Cluster) (
|
||||||
|
|
||||||
var currentClusterStatus = v1alpha1.ClusterStatus{}
|
var currentClusterStatus = v1alpha1.ClusterStatus{}
|
||||||
|
|
||||||
// get the health status of member cluster
|
var online, healthy bool
|
||||||
online, healthy := getClusterHealthStatus(clusterClient)
|
|
||||||
|
|
||||||
// in case of cluster offline, retry a few times to avoid network unstable problems.
|
// in case of cluster offline, retry a few times to avoid network unstable problems.
|
||||||
// Note: retry timeout should not be too long, otherwise will block other cluster reconcile.
|
// Note: retry timeout should not be too long, otherwise will block other cluster reconcile.
|
||||||
if !online {
|
err = wait.PollImmediate(clusterStatusRetryInterval, clusterStatusRetryTimeout, func() (done bool, err error) {
|
||||||
err := wait.Poll(clusterStatusRetryInterval, clusterStatusRetryTimeout, func() (done bool, err error) {
|
online, healthy = getClusterHealthStatus(clusterClient)
|
||||||
online, healthy = getClusterHealthStatus(clusterClient)
|
if !online {
|
||||||
if !online {
|
return false, nil
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
klog.V(2).Infof("Cluster(%s) back to online after retry.", cluster.Name)
|
|
||||||
return true, nil
|
|
||||||
})
|
|
||||||
// error indicates that retry timeout, update cluster status immediately and return.
|
|
||||||
if err != nil {
|
|
||||||
currentClusterStatus.Conditions = generateReadyCondition(false, false)
|
|
||||||
setTransitionTime(&cluster.Status, ¤tClusterStatus)
|
|
||||||
return c.updateStatusIfNeeded(cluster, currentClusterStatus)
|
|
||||||
}
|
}
|
||||||
|
klog.V(2).Infof("Cluster(%s) back to online after retry.", cluster.Name)
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
// error indicates that retry timeout, update cluster status immediately and return.
|
||||||
|
if err != nil {
|
||||||
|
currentClusterStatus.Conditions = generateReadyCondition(false, false)
|
||||||
|
setTransitionTime(&cluster.Status, ¤tClusterStatus)
|
||||||
|
return c.updateStatusIfNeeded(cluster, currentClusterStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
clusterVersion, err := getKubernetesVersion(clusterClient)
|
clusterVersion, err := getKubernetesVersion(clusterClient)
|
||||||
|
|
Loading…
Reference in New Issue