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,12 +304,14 @@ 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 {
err := gce.InsertInstance(
gceProjectId, gceProjectId,
zoneName, zoneName,
&compute.Instance{ &compute.Instance{
@ -323,6 +325,7 @@ func createAndInsertNodes(gce *GCECloud, nodeNames []string) ([]*v1.Node, error)
if err != nil { if err != nil {
return nodes, err return nodes, err
} }
}
nodes = append( nodes = append(
nodes, nodes,
@ -340,6 +343,7 @@ func createAndInsertNodes(gce *GCECloud, nodeNames []string) ([]*v1.Node, error)
}, },
}, },
) )
} }
return nodes, nil return nodes, nil