Detect if UpdateTCPLoadBalancer left its GCE target pool in an incorrect state.

This commit is contained in:
Alex Robinson 2015-07-16 00:18:27 +00:00
parent 1be091da07
commit b0351ff266

View File

@ -479,6 +479,19 @@ func (gce *GCECloud) UpdateTCPLoadBalancer(name, region string, hosts []string)
return err return err
} }
} }
// Try to verify that the correct number of nodes are now in the target pool.
// We've been bitten by a bug here before (#11327) where all nodes were
// accidentally removed and want to make similar problems easier to notice.
updatedPool, err := gce.service.TargetPools.Get(gce.projectID, region, name).Do()
if err != nil {
return err
}
if len(updatedPool.Instances) != len(hosts) {
glog.Errorf("Unexpected number of instances (%d) in target pool %s after updating (expected %d). Instances in updated pool: %s",
len(updatedPool.Instances), name, len(hosts), strings.Join(updatedPool.Instances, ","))
return fmt.Errorf("Unexpected number of instances (%d) in target pool %s after update (expected %d)", len(updatedPool.Instances), name, len(hosts))
}
return nil return nil
} }