Skip to content

Commit

Permalink
remove getAlphaInstanceGroupsToAdd
Browse files Browse the repository at this point in the history
  • Loading branch information
agau4779 committed Mar 30, 2018
1 parent b462cdc commit e1ac2c3
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions pkg/backends/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,7 @@ func (b *Backends) ensureBackendService(p ServicePort, igs []*compute.InstanceGr
// edgeHop checks the links of the given backend by executing an edge hop.
// It fixes broken links and updates the Backend accordingly.
func (b *Backends) edgeHop(be *BackendService, igs []*compute.InstanceGroup) error {
addIGs := []*compute.InstanceGroup{}
if be.Alpha != nil {
addIGs = getAlphaInstanceGroupsToAdd(be, igs)
} else {
addIGs = getInstanceGroupsToAdd(be, igs)
}
addIGs := getInstanceGroupsToAdd(be, igs)
if len(addIGs) == 0 {
return nil
}
Expand Down Expand Up @@ -598,6 +593,8 @@ func getBackendsForNEGs(negs []*computealpha.NetworkEndpointGroup) []*computealp
}

func getInstanceGroupsToAdd(be *BackendService, igs []*compute.InstanceGroup) []*compute.InstanceGroup {
// A GA link can be used to reference an alpha object - so we only need to
// check the GA InstanceGroups.
beName := be.Ga.Name
beIGs := sets.String{}
for _, existingBe := range be.Ga.Backends {
Expand Down Expand Up @@ -625,34 +622,6 @@ func getInstanceGroupsToAdd(be *BackendService, igs []*compute.InstanceGroup) []
return addIGs
}

func getAlphaInstanceGroupsToAdd(be *BackendService, igs []*compute.InstanceGroup) []*compute.InstanceGroup {
beName := be.Alpha.Name
beIGs := sets.String{}
for _, existingBe := range be.Alpha.Backends {
beIGs.Insert(comparableGroupPath(existingBe.Group))
}

expectedIGs := sets.String{}
for _, ig := range igs {
expectedIGs.Insert(comparableGroupPath(ig.SelfLink))
}

if beIGs.IsSuperset(expectedIGs) {
return nil
}
glog.V(2).Infof("Expected igs for backend service %v: %+v, current igs %+v",
beName, expectedIGs.List(), beIGs.List())

var addIGs []*compute.InstanceGroup
for _, ig := range igs {
if !beIGs.Has(comparableGroupPath(ig.SelfLink)) {
addIGs = append(addIGs, ig)
}
}

return addIGs
}

// GC garbage collects services corresponding to ports in the given list.
func (b *Backends) GC(svcNodePorts []ServicePort) error {
knownPorts := sets.NewString()
Expand Down

0 comments on commit e1ac2c3

Please sign in to comment.