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 #237 from joshwget/v2-lb-selectors
Browse files Browse the repository at this point in the history
Fix selectors for v2 load balancers
  • Loading branch information
ibuildthecloud authored Nov 30, 2016
2 parents b6bed20 + 9b7219c commit 2706944
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions rancher/lb_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,29 @@ frontend %s
}
}
for _, portRule := range config.LbConfig.PortRules {
targetService, err := r.FindExisting(portRule.Service)
if err != nil {
return err
}
if targetService == nil {
return fmt.Errorf("Failed to find existing service: %s", portRule.Service)
}
service.LbConfig.PortRules = append(service.LbConfig.PortRules, client.PortRule{
finalPortRule := client.PortRule{
SourcePort: int64(portRule.SourcePort),
Protocol: portRule.Protocol,
Path: portRule.Path,
Hostname: portRule.Hostname,
ServiceId: targetService.Id,
TargetPort: int64(portRule.TargetPort),
Priority: int64(portRule.Priority),
BackendName: portRule.BackendName,
Selector: portRule.Selector,
})
}

if portRule.Service != "" {
targetService, err := r.FindExisting(portRule.Service)
if err != nil {
return err
}
if targetService == nil {
return fmt.Errorf("Failed to find existing service: %s", portRule.Service)
}
finalPortRule.ServiceId = targetService.Id
}

service.LbConfig.PortRules = append(service.LbConfig.PortRules, finalPortRule)
}

launchConfig.Ports = r.serviceConfig.Ports
Expand Down
2 changes: 1 addition & 1 deletion rancher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (r *RancherService) DependentServices() []project.ServiceRelationship {
lbConfig := r.RancherConfig().LbConfig
if lbConfig != nil {
for _, portRule := range lbConfig.PortRules {
if !strings.Contains(portRule.Service, "/") {
if portRule.Service != "" && !strings.Contains(portRule.Service, "/") {
result = append(result, project.NewServiceRelationship(portRule.Service, project.RelTypeLink))
}
}
Expand Down

0 comments on commit 2706944

Please sign in to comment.