Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #247 from joshwget/skip-links-for-lb
Browse files Browse the repository at this point in the history
Don't activate links for load balancers
  • Loading branch information
ibuildthecloud authored Mar 7, 2017
2 parents 4174e64 + f653f85 commit b80ddd8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
26 changes: 0 additions & 26 deletions rancher/lb_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,10 @@ import (
"strconv"
"strings"

"github.com/docker/libcompose/utils"
legacyClient "github.com/rancher/go-rancher/client"
"github.com/rancher/go-rancher/v2"
)

// Links to target services should be automatically added to load balancers
func (r *RancherService) populateLbLinks() error {
links, err := r.getLinks()
if err != nil {
return err
}

var linkServiceNames []string
for link := range links {
linkServiceNames = append(linkServiceNames, link.ServiceName)
}

lbConfig := r.RancherConfig().LbConfig
serviceType := FindServiceType(r)
if lbConfig != nil && (serviceType == LbServiceType || serviceType == LegacyLbServiceType) {
for _, portRule := range lbConfig.PortRules {
if portRule.Service != "" && !utils.Contains(linkServiceNames, portRule.Service) {
r.serviceConfig.Links = append(r.serviceConfig.Links, portRule.Service)
}
}
}

return nil
}

func populateLbFields(r *RancherService, launchConfig *client.LaunchConfig, service *CompositeService) error {
serviceType := FindServiceType(r)

Expand Down
4 changes: 0 additions & 4 deletions rancher/normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ func (f *NormalFactory) Hash(service *RancherService) (digest.ServiceHash, error
}

func (f *NormalFactory) configAndHash(r *RancherService) (digest.ServiceHash, *CompositeService, error) {
if err := r.populateLbLinks(); err != nil {
return digest.ServiceHash{}, nil, err
}

rancherService, launchConfig, secondaryLaunchConfigs, err := f.config(r)
if err != nil {
return digest.ServiceHash{}, nil, err
Expand Down
3 changes: 2 additions & 1 deletion rancher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ func (r *RancherService) createService() (*client.Service, error) {

func (r *RancherService) setupLinks(service *client.Service, update bool) error {
// Don't modify links for selector based linking, don't want to conflict
if service.SelectorLink != "" || FindServiceType(r) == ExternalServiceType {
// Don't modify links for load balancers, they're created by cattle
if service.SelectorLink != "" || FindServiceType(r) == ExternalServiceType || FindServiceType(r) == LbServiceType {
return nil
}

Expand Down

0 comments on commit b80ddd8

Please sign in to comment.