Skip to content

Commit

Permalink
Merge pull request kubernetes#48309 from MrHohn/e2e-fix-ingress-tag
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

[e2e-ingress] Get node tag from instance under GKE

**What this PR does / why we need it**: Making ingress CI green again.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes kubernetes#48167 

**Special notes for your reviewer**:
/assign @nicksardo 

**Release note**:

```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue authored Jul 5, 2017
2 parents 145976f + 532a9d7 commit afc67bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions test/e2e/framework/firewall_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ func SetInstanceTags(cloudConfig CloudConfig, instanceName, zone string, tags []
return resTags.Items
}

// GetNodeTags gets k8s node tag from one of the nodes
func GetNodeTags(c clientset.Interface, cloudConfig CloudConfig) []string {
nodes := GetReadySchedulableNodesOrDie(c)
if len(nodes.Items) == 0 {
Logf("GetNodeTags: Found 0 node.")
return []string{}
}
return GetInstanceTags(cloudConfig, nodes.Items[0].Name).Items
}

// GetInstancePrefix returns the INSTANCE_PREFIX env we set for e2e cluster.
// From cluster/gce/config-test.sh, master name is set up using below format:
// MASTER_NAME="${INSTANCE_PREFIX}-master"
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/ingress_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,13 @@ func (j *IngressTestJig) GetIngressNodePorts() []string {
}

// ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource
func (j *IngressTestJig) ConstructFirewallForIngress(gceController *GCEIngressController, nodeTag string) *compute.Firewall {
func (j *IngressTestJig) ConstructFirewallForIngress(gceController *GCEIngressController, nodeTags []string) *compute.Firewall {
nodePorts := j.GetIngressNodePorts()

fw := compute.Firewall{}
fw.Name = gceController.GetFirewallRuleName()
fw.SourceRanges = gcecloud.LoadBalancerSrcRanges()
fw.TargetTags = []string{nodeTag}
fw.TargetTags = nodeTags
fw.Allowed = []*compute.FirewallAllowed{
{
IPProtocol: "tcp",
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ var _ = framework.KubeDescribe("Loadbalancing: L7", func() {

By("should have correct firewall rule for ingress")
fw := gceController.GetFirewallRule()
expFw := jig.ConstructFirewallForIngress(gceController, cloudConfig.NodeTag)
nodeTags := []string{cloudConfig.NodeTag}
if framework.TestContext.Provider != "gce" {
// nodeTags would be different in GKE.
nodeTags = framework.GetNodeTags(jig.Client, cloudConfig)
}
expFw := jig.ConstructFirewallForIngress(gceController, nodeTags)
// Passed the last argument as `true` to verify the backend ports is a subset
// of the allowed ports in firewall rule, given there may be other existing
// ingress resources and backends we are not aware of.
Expand Down

0 comments on commit afc67bd

Please sign in to comment.