跳到主要内容

27.cloudminon

PR #244

Add a minion registry that is backed by a cloud provider.

云厂商需要实现查询 云主机列表 这个接口

type Instances interface {
IPAddress(name string) (net.IP, error)
// Lists instances that match 'filter' which is a regular expression which must match the entire instance name
List(filter string) ([]string, error)
}

实现了一个新的 基于cloud 的 Minionregistry ,目前只支持 查询 列表。

PR #259

Implement client polling. [客户端实现轮训]

                if statusErr.Status.Status == api.StatusWorking && r.pollPeriod != 0 {
time.Sleep(r.pollPeriod)
// Make a poll request
pollOp := r.c.PollFor(statusErr.Status.Details).PollPeriod(r.pollPeriod)
// Could also say "return r.Do()" but this way doesn't grow the callstack.
r = pollOp
continue
}

如果状态是正在执行,并且设置了pollPeriod,不断重试。

PR #238

为 google I/O 大会准备demo,大家可以看下面的视频

https://www.youtube.com/watch?v=tsk0pWf4ipw&t=2201s

PR #257

Implement sync behavior for controllers. [实现控制器 同步等待]

在创建 controller 或者更新 controller 时候,添加等待逻辑

func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
controller, ok := obj.(api.ReplicationController)
if !ok {
return nil, fmt.Errorf("not a replication controller: %#v", obj)
}
if controller.ID == "" {
return nil, fmt.Errorf("ID should not be empty: %#v", controller)
}
return apiserver.MakeAsync(func() (interface{}, error) {
err := storage.registry.UpdateController(controller)
if err != nil {
return nil, err
}
return storage.waitForController(controller)
}), nil
}

func (storage *ControllerRegistryStorage) waitForController(ctrl api.ReplicationController) (interface{}, error) {
for {
pods, err := storage.podRegistry.ListPods(labels.Set(ctrl.DesiredState.ReplicaSelector).AsSelector())
if err != nil {
return ctrl, err
}
if len(pods) == ctrl.DesiredState.Replicas {
break
}
time.Sleep(storage.pollPeriod)
}
return ctrl, nil
}