Skip to content

Commit

Permalink
Merge pull request #6 from prachidamle/add_env_id_to_rancher_suffix
Browse files Browse the repository at this point in the history
Add environment UUID to rancher suffix added on LB targets
  • Loading branch information
prachidamle committed Apr 28, 2016
2 parents 96a2740 + 94cf6c6 commit 058db1d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion external-lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ func getProviderLBConfigs() (map[string]model.LBConfig, error) {
return nil, err
}
rancherConfigs := make(map[string]model.LBConfig, len(allConfigs))
suffix := "_" + m.EnvironmentUUID + "_" + targetRancherSuffix
for _, value := range allConfigs {
if strings.HasSuffix(value.LBTargetPoolName, targetRancherSuffix) {
if strings.HasSuffix(value.LBTargetPoolName, suffix) {
rancherConfigs[value.LBEndpoint] = value
}
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func setEnv() {

targetRancherSuffix = os.Getenv("LB_TARGET_RANCHER_SUFFIX")
if len(targetRancherSuffix) == 0 {
logrus.Info("LB_TARGET_RANCHER_SUFFIX is not set, using default suffix '_rancher.internal'")
targetRancherSuffix = "_rancher.internal"
logrus.Info("LB_TARGET_RANCHER_SUFFIX is not set, using default suffix 'rancher.internal'")
targetRancherSuffix = "rancher.internal"
}

lbEndpointServiceLabel = "io.rancher.service.external_lb_endpoint"
Expand Down
14 changes: 8 additions & 6 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ const (
)

type MetadataClient struct {
MetadataClient *metadata.Client
MetadataClient *metadata.Client
EnvironmentUUID string
}

func getEnvironmentName(m *metadata.Client) (string, error) {
func getEnvironmentUUID(m *metadata.Client) (string, error) {
timeout := 30 * time.Second
var err error
var stack metadata.Stack
Expand All @@ -27,7 +28,7 @@ func getEnvironmentName(m *metadata.Client) (string, error) {
logrus.Errorf("Error reading stack info: %v...will retry", err)
time.Sleep(i)
} else {
return stack.EnvironmentName, nil
return stack.EnvironmentUUID, nil
}
}
return "", fmt.Errorf("Error reading stack info: %v", err)
Expand All @@ -39,13 +40,14 @@ func NewMetadataClient() (*MetadataClient, error) {
logrus.Fatalf("Failed to configure rancher-metadata: %v", err)
}

_, err = getEnvironmentName(m)
envUUID, err := getEnvironmentUUID(m)
if err != nil {
logrus.Fatalf("Error reading stack metadata info: %v", err)
}

return &MetadataClient{
MetadataClient: m,
MetadataClient: m,
EnvironmentUUID: envUUID,
}, nil
}

Expand Down Expand Up @@ -75,7 +77,7 @@ func (m *MetadataClient) GetMetadataLBConfigs(lbEndpointServiceLabel string, tar
logrus.Debugf("LB label exists for service : %v", service)
lbConfig := model.LBConfig{}
lbConfig.LBEndpoint = lb_endpoint
lbConfig.LBTargetPoolName = service.UUID + targetRancherSuffix
lbConfig.LBTargetPoolName = service.Name + "_" + m.EnvironmentUUID + "_" + targetRancherSuffix
if err = m.getContainerLBTargets(&lbConfig, service); err != nil {
continue
}
Expand Down

0 comments on commit 058db1d

Please sign in to comment.