Merge pull request #61987 from nikhiljindal/ingressTest

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Getting error from GetFirewallRule and checking it to fix multicluster ingress test

Fixes https://github.com/kubernetes/kubernetes/pull/61909#issuecomment-377704479

Adding a GetFirewallRuleOrError method that returns the error rather than failing and using that in our multicluster ingress test.

cc @nicksardo @MrHohn @G-Harmon @csbell 

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-04-02 14:06:32 -07:00 committed by GitHub
commit 863d1f5f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -864,14 +864,24 @@ func (cont *GCEIngressController) GetFirewallRuleName() string {
}
// GetFirewallRule returns the firewall used by the GCEIngressController.
// Causes a fatal error incase of an error.
// TODO: Rename this to GetFirewallRuleOrDie and similarly rename all other
// methods here to be consistent with rest of the code in this repo.
func (cont *GCEIngressController) GetFirewallRule() *compute.Firewall {
gceCloud := cont.Cloud.Provider.(*gcecloud.GCECloud)
fwName := cont.GetFirewallRuleName()
fw, err := gceCloud.GetFirewall(fwName)
fw, err := cont.GetFirewallRuleOrError()
Expect(err).NotTo(HaveOccurred())
return fw
}
// GetFirewallRule returns the firewall used by the GCEIngressController.
// Returns an error if that fails.
// TODO: Rename this to GetFirewallRule when the above method with that name is renamed.
func (cont *GCEIngressController) GetFirewallRuleOrError() (*compute.Firewall, error) {
gceCloud := cont.Cloud.Provider.(*gcecloud.GCECloud)
fwName := cont.GetFirewallRuleName()
return gceCloud.GetFirewall(fwName)
}
func (cont *GCEIngressController) deleteFirewallRule(del bool) (msg string) {
fwList := []compute.Firewall{}
regex := fmt.Sprintf("%vfw-l7%v.*", k8sPrefix, clusterDelimiter)

View File

@ -386,8 +386,8 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
framework.Failf("unexpected backend service, expected none, got: %v", gceController.ListGlobalBackendServices())
}
// Controller does not have a list command for firewall rule. We use get instead.
if gceController.GetFirewallRule() != nil {
framework.Failf("unexpected firewall rule, expected none got: %v", gceController.GetFirewallRule())
if fw, err := gceController.GetFirewallRuleOrError(); err == nil {
framework.Failf("unexpected nil error in getting firewall rule, expected firewall NotFound, got firewall: %v", fw)
}
// TODO(nikhiljindal): Check the instance group annotation value and verify with a multizone cluster.