37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wait.go 891 Bytes
一键复制 编辑 原始数据 按行查看 历史
package compose
import (
"time"
"github.com/pkg/errors"
"github.com/rancher/norman/clientbase"
managementClient "github.com/rancher/types/client/management/v3"
)
var (
// WaitCondition is a set of function that can be customized to wait for a resource
WaitCondition = map[string]func(baseClient *clientbase.APIBaseClient, id, schemaType string) error{}
)
func WaitCluster(baseClient *clientbase.APIBaseClient, id, schemaType string) error {
start := time.Now()
for {
respObj := managementClient.Cluster{}
if err := baseClient.ByID(schemaType, id, &respObj); err != nil {
return err
}
for _, cond := range respObj.Conditions {
if cond.Type == "Ready" && cond.Status == "True" {
return nil
}
}
time.Sleep(time.Second * 10)
if time.Now().After(start.Add(time.Minute * 30)) {
return errors.Errorf("Timeout wait for cluster %s to be ready", id)
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.5-rc5

搜索帮助

0d507c66 1850385 C8b1a773 1850385