Made CleanupGCEResources explicitly take zone parameter
This commit is contained in:
		@@ -1300,9 +1300,17 @@ func VerifyServeHostnameServiceDown(c clientset.Interface, host string, serviceI
 | 
				
			|||||||
	return fmt.Errorf("waiting for service to be down timed out")
 | 
						return fmt.Errorf("waiting for service to be down timed out")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func CleanupServiceGCEResources(loadBalancerName string) {
 | 
					func CleanupServiceResources(loadBalancerName, zone string) {
 | 
				
			||||||
 | 
						if TestContext.Provider == "gce" || TestContext.Provider == "gke" {
 | 
				
			||||||
 | 
							CleanupServiceGCEResources(loadBalancerName, zone)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// TODO: we need to add this function with other cloud providers, if there is a need.
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func CleanupServiceGCEResources(loadBalancerName, zone string) {
 | 
				
			||||||
	if pollErr := wait.Poll(5*time.Second, LoadBalancerCleanupTimeout, func() (bool, error) {
 | 
						if pollErr := wait.Poll(5*time.Second, LoadBalancerCleanupTimeout, func() (bool, error) {
 | 
				
			||||||
		if err := CleanupGCEResources(loadBalancerName); err != nil {
 | 
							if err := CleanupGCEResources(loadBalancerName, zone); err != nil {
 | 
				
			||||||
			Logf("Still waiting for glbc to cleanup: %v", err)
 | 
								Logf("Still waiting for glbc to cleanup: %v", err)
 | 
				
			||||||
			return false, nil
 | 
								return false, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5158,21 +5158,25 @@ func (p *E2ETestNodePreparer) CleanupNodes() error {
 | 
				
			|||||||
// CleanupGCEResources cleans up GCE Service Type=LoadBalancer resources with
 | 
					// CleanupGCEResources cleans up GCE Service Type=LoadBalancer resources with
 | 
				
			||||||
// the given name. The name is usually the UUID of the Service prefixed with an
 | 
					// the given name. The name is usually the UUID of the Service prefixed with an
 | 
				
			||||||
// alpha-numeric character ('a') to work around cloudprovider rules.
 | 
					// alpha-numeric character ('a') to work around cloudprovider rules.
 | 
				
			||||||
func CleanupGCEResources(loadBalancerName string) (retErr error) {
 | 
					func CleanupGCEResources(loadBalancerName, zone string) (retErr error) {
 | 
				
			||||||
	gceCloud, err := GetGCECloud()
 | 
						gceCloud, err := GetGCECloud()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						region, err := gcecloud.GetGCERegion(zone)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return fmt.Errorf("error parsing GCE/GKE region from zone %q: %v", zone, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if err := gceCloud.DeleteFirewall(loadBalancerName); err != nil &&
 | 
						if err := gceCloud.DeleteFirewall(loadBalancerName); err != nil &&
 | 
				
			||||||
		!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
 | 
							!IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) {
 | 
				
			||||||
		retErr = err
 | 
							retErr = err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := gceCloud.DeleteRegionForwardingRule(loadBalancerName, gceCloud.Region()); err != nil &&
 | 
						if err := gceCloud.DeleteRegionForwardingRule(loadBalancerName, 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.DeleteRegionAddress(loadBalancerName, gceCloud.Region()); err != nil &&
 | 
						if err := gceCloud.DeleteRegionAddress(loadBalancerName, 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)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -5185,7 +5189,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.DeleteExternalTargetPoolAndChecks(loadBalancerName, gceCloud.Region(), hcNames...); err != nil &&
 | 
						if err := gceCloud.DeleteExternalTargetPoolAndChecks(loadBalancerName, 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)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ var _ = framework.KubeDescribe("Services", func() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		for _, lb := range serviceLBNames {
 | 
							for _, lb := range serviceLBNames {
 | 
				
			||||||
			framework.Logf("cleaning gce resource for %s", lb)
 | 
								framework.Logf("cleaning gce resource for %s", lb)
 | 
				
			||||||
			framework.CleanupServiceGCEResources(lb)
 | 
								framework.CleanupServiceGCEResources(lb, framework.TestContext.CloudConfig.Zone)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		//reset serviceLBNames
 | 
							//reset serviceLBNames
 | 
				
			||||||
		serviceLBNames = []string{}
 | 
							serviceLBNames = []string{}
 | 
				
			||||||
@@ -1266,7 +1266,7 @@ var _ = framework.KubeDescribe("ESIPP [Slow]", func() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		for _, lb := range serviceLBNames {
 | 
							for _, lb := range serviceLBNames {
 | 
				
			||||||
			framework.Logf("cleaning gce resource for %s", lb)
 | 
								framework.Logf("cleaning gce resource for %s", lb)
 | 
				
			||||||
			framework.CleanupServiceGCEResources(lb)
 | 
								framework.CleanupServiceGCEResources(lb, framework.TestContext.CloudConfig.Zone)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		//reset serviceLBNames
 | 
							//reset serviceLBNames
 | 
				
			||||||
		serviceLBNames = []string{}
 | 
							serviceLBNames = []string{}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user