Update test utilities & build file

This commit is contained in:
Nick Sardo
2017-06-01 15:26:05 -07:00
parent 05aaef3edc
commit 7248c61ea5
3 changed files with 12 additions and 11 deletions

View File

@@ -13,6 +13,8 @@ go_library(
srcs = [ srcs = [
"doc.go", "doc.go",
"gce.go", "gce.go",
"gce_addresses.go",
"gce_annotations.go",
"gce_backendservice.go", "gce_backendservice.go",
"gce_cert.go", "gce_cert.go",
"gce_clusterid.go", "gce_clusterid.go",
@@ -24,9 +26,12 @@ go_library(
"gce_instancegroup.go", "gce_instancegroup.go",
"gce_instances.go", "gce_instances.go",
"gce_loadbalancer.go", "gce_loadbalancer.go",
"gce_loadbalancer_external.go",
"gce_loadbalancer_internal.go",
"gce_loadbalancer_naming.go",
"gce_op.go", "gce_op.go",
"gce_routes.go", "gce_routes.go",
"gce_staticip.go", "gce_targetpool.go",
"gce_targetproxy.go", "gce_targetproxy.go",
"gce_urlmap.go", "gce_urlmap.go",
"gce_util.go", "gce_util.go",

View File

@@ -717,9 +717,10 @@ func (cont *GCEIngressController) Init() {
// invoking deleteStaticIPs. // invoking deleteStaticIPs.
func (cont *GCEIngressController) CreateStaticIP(name string) string { func (cont *GCEIngressController) CreateStaticIP(name string) string {
gceCloud := cont.Cloud.Provider.(*gcecloud.GCECloud) gceCloud := cont.Cloud.Provider.(*gcecloud.GCECloud)
ip, err := gceCloud.ReserveGlobalStaticIP(name, "") addr := &compute.Address{Name: name}
ip, err := gceCloud.ReserveGlobalAddress(addr)
if err != nil { if err != nil {
if delErr := gceCloud.DeleteGlobalStaticIP(name); delErr != nil { if delErr := gceCloud.DeleteGlobalAddress(name); delErr != nil {
if cont.isHTTPErrorCode(delErr, http.StatusNotFound) { if cont.isHTTPErrorCode(delErr, http.StatusNotFound) {
Logf("Static ip with name %v was not allocated, nothing to delete", name) Logf("Static ip with name %v was not allocated, nothing to delete", name)
} else { } else {

View File

@@ -5167,20 +5167,15 @@ func CleanupGCEResources(loadBalancerName string) (retErr error) {
!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) { !IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
retErr = err retErr = err
} }
if err := gceCloud.DeleteForwardingRule(loadBalancerName); err != nil && if err := gceCloud.DeleteRegionForwardingRule(loadBalancerName, gceCloud.Region()); err != nil &&
!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) { !IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
retErr = fmt.Errorf("%v\n%v", retErr, err) retErr = fmt.Errorf("%v\n%v", retErr, err)
} }
if err := gceCloud.DeleteGlobalStaticIP(loadBalancerName); err != nil && if err := gceCloud.DeleteRegionAddress(loadBalancerName, gceCloud.Region()); err != nil &&
!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) { !IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
retErr = fmt.Errorf("%v\n%v", retErr, err) retErr = fmt.Errorf("%v\n%v", retErr, err)
} }
// This function shells out to gcloud, so we can't compare for NotFound errors.
// TODO: Invoke cloudprovider method directly instead.
if err := DeleteGCEStaticIP(loadBalancerName); err != nil {
Logf("%v", err)
}
var hcNames []string var hcNames []string
hc, getErr := gceCloud.GetHttpHealthCheck(loadBalancerName) hc, getErr := gceCloud.GetHttpHealthCheck(loadBalancerName)
if getErr != nil && !IsGoogleAPIHTTPErrorCode(getErr, http.StatusNotFound) { if getErr != nil && !IsGoogleAPIHTTPErrorCode(getErr, http.StatusNotFound) {
@@ -5190,7 +5185,7 @@ func CleanupGCEResources(loadBalancerName string) (retErr error) {
if hc != nil { if hc != nil {
hcNames = append(hcNames, hc.Name) hcNames = append(hcNames, hc.Name)
} }
if err := gceCloud.DeleteTargetPool(loadBalancerName, hcNames...); err != nil && if err := gceCloud.DeleteExternalTargetPoolAndChecks(loadBalancerName, gceCloud.Region(), hcNames...); err != nil &&
!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) { !IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
retErr = fmt.Errorf("%v\n%v", retErr, err) retErr = fmt.Errorf("%v\n%v", retErr, err)
} }