Skip to content

Commit

Permalink
lb.instance.image from list
Browse files Browse the repository at this point in the history
  • Loading branch information
Alena Prokharchyk committed Nov 14, 2016
1 parent 8a3cc15 commit 95f43c9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pkg/cloudprovider/providers/rancher/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ func (r *CloudProvider) EnsureLoadBalancer(clusterName string, service *api.Serv
lb = nil
}

var imageUUID string
imageUUID, fetched := r.GetSetting("lb.instance.image")
if !fetched || imageUUID == "" {
return nil, fmt.Errorf("Failed to fetch lb.instance.image setting")
}
imageUUID = fmt.Sprintf("docker:%s", imageUUID)

if lb == nil {
env, err := r.getOrCreateEnvironment()
if err != nil {
Expand All @@ -174,7 +181,7 @@ func (r *CloudProvider) EnsureLoadBalancer(clusterName string, service *api.Serv
StackId: env.Id,
LaunchConfig: &client.LaunchConfig{
Ports: lbPorts,
ImageUuid: "docker:rancher/lb-service-haproxy:latest",
ImageUuid: imageUUID,
},
LbConfig: &client.LbConfig{},
}
Expand Down Expand Up @@ -235,6 +242,24 @@ func (r *CloudProvider) EnsureLoadBalancer(clusterName string, service *api.Serv
return status, nil
}

func (r *CloudProvider) GetSetting(key string) (string, bool) {
opts := client.NewListOpts()
opts.Filters["name"] = key
settings, err := r.client.Setting.List(opts)
if err != nil {
glog.Errorf("GetSetting(%s): Error: %s", key, err)
return "", false
}

for _, data := range settings.Data {
if strings.EqualFold(data.Name, key) {
return data.Value, true
}
}

return "", false
}

func (r *CloudProvider) waitForLBPublicEndpoints(count int, lb *client.LoadBalancerService) <-chan interface{} {
cb := func(result chan<- interface{}) (bool, error) {
lb, err := r.reloadLBService(lb)
Expand Down

0 comments on commit 95f43c9

Please sign in to comment.