use getInstanceByName to check for node presence, instead of DeleteInstance)

This commit is contained in:
Ashley Gau 2018-02-07 14:36:08 -08:00
parent 378b177f02
commit 41070a2f58

View File

@ -304,24 +304,27 @@ func createAndInsertNodes(gce *GCECloud, nodeNames []string) ([]*v1.Node, error)
nodes := []*v1.Node{} nodes := []*v1.Node{}
for _, name := range nodeNames { for _, name := range nodeNames {
// Inserting the same node name twice causes an error - here we call // Inserting the same node name twice causes an error - here we check if
// DeleteInstance to guarantee that nodes aren't inserted twice. // the instance exists already before insertion.
// See TestUpdateExternalLoadBalancer. // TestUpdateExternalLoadBalancer inserts a new node, and relies on an older
err := gce.DeleteInstance(gceProjectId, zoneName, name) // node to already have been inserted.
instance, _ := gce.getInstanceByName(name)
err = gce.InsertInstance( if instance == nil {
gceProjectId, err := gce.InsertInstance(
zoneName, gceProjectId,
&compute.Instance{ zoneName,
Name: name, &compute.Instance{
Tags: &compute.Tags{ Name: name,
Items: []string{name}, Tags: &compute.Tags{
Items: []string{name},
},
}, },
}, )
)
if err != nil { if err != nil {
return nodes, err return nodes, err
}
} }
nodes = append( nodes = append(
@ -340,6 +343,7 @@ func createAndInsertNodes(gce *GCECloud, nodeNames []string) ([]*v1.Node, error)
}, },
}, },
) )
} }
return nodes, nil return nodes, nil