From f653f8552d7300ab97d5e87416abaa9b7ab8db09 Mon Sep 17 00:00:00 2001 From: Josh Curl Date: Mon, 6 Mar 2017 15:47:39 -0800 Subject: [PATCH] Don't activate links for load balancers --- rancher/lb_service.go | 26 -------------------------- rancher/normal.go | 4 ---- rancher/service.go | 3 ++- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/rancher/lb_service.go b/rancher/lb_service.go index 527cd00b..933df93d 100644 --- a/rancher/lb_service.go +++ b/rancher/lb_service.go @@ -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) diff --git a/rancher/normal.go b/rancher/normal.go index c4d92834..de2ef47f 100644 --- a/rancher/normal.go +++ b/rancher/normal.go @@ -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 diff --git a/rancher/service.go b/rancher/service.go index 5ae3ffa9..6703a728 100644 --- a/rancher/service.go +++ b/rancher/service.go @@ -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 }