Remove multiple calls to CreateInstanceGroups by reusing results from a single call

This commit is contained in:
nikhiljindal 2017-09-11 20:29:49 -07:00
parent 0f4f5c97d4
commit 937cde666e
10 changed files with 68 additions and 75 deletions

View file

@ -63,8 +63,7 @@ func (i *Instances) Init(zl zoneLister) {
// all of which have the exact same named port.
func (i *Instances) AddInstanceGroup(name string, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
igs := []*compute.InstanceGroup{}
// TODO: move port naming to namer
namedPort := &compute.NamedPort{Name: fmt.Sprintf("port%v", port), Port: port}
namedPort := utils.GetNamedPort(port)
zones, err := i.ListZones()
if err != nil {

View file

@ -8,6 +8,6 @@ import (
// Helper method to create instance groups.
// This method exists to ensure that we are using the same logic at all places.
func CreateInstanceGroups(nodePool NodePool, namer *utils.Namer, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
func EnsureInstanceGroupsAndPorts(nodePool NodePool, namer *utils.Namer, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
return nodePool.AddInstanceGroup(namer.IGName(), port)
}