Skip to content

Commit

Permalink
listeners: ignore nil fields when constructing listenerID (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
draychev authored and akshaysngupta committed Oct 29, 2019
1 parent 5b9aa7b commit cccb76c
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 185 deletions.
239 changes: 239 additions & 0 deletions functional_tests/duplicate_ports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"properties": {
"backendAddressPools": [
{
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendAddressPools/defaultaddresspool",
"name": "defaultaddresspool",
"properties": {
"backendAddresses": []
}
},
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendAddressPools/pool---namespace---hello-world-80-bp-80",
"name": "pool---namespace---hello-world-80-bp-80",
"properties": {
"backendAddresses": [
{
"ipAddress": "1.1.1.1"
},
{
"ipAddress": "1.1.1.2"
},
{
"ipAddress": "1.1.1.3"
}
]
}
}
],
"backendHttpSettingsCollection": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendHttpSettingsCollection/bp---namespace---hello-world-80-80---name--",
"name": "bp---namespace---hello-world-80-80---name--",
"properties": {
"port": 80,
"probe": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/probes/pb---namespace---hello-world-80---name--"
},
"protocol": "Http"
}
},
{
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendHttpSettingsCollection/defaulthttpsetting",
"name": "defaulthttpsetting",
"properties": {
"port": 80,
"probe": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/probes/defaultprobe-Http"
},
"protocol": "Http"
}
}
],
"frontendIPConfigurations": [
{
"etag": "xx2",
"id": "--front-end-ip-id-1--",
"name": "xx3",
"properties": {
"publicIPAddress": {
"id": "xyz"
}
},
"type": "xx1"
},
{
"etag": "yy2",
"id": "--front-end-ip-id-2--",
"name": "yy3",
"properties": {
"privateIPAddress": "abc"
},
"type": "yy1"
}
],
"frontendPorts": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/frontendPorts/fp-443",
"name": "fp-443",
"properties": {
"port": 443
}
},
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/frontendPorts/fp-80",
"name": "fp-80",
"properties": {
"port": 80
}
}
],
"httpListeners": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/httpListeners/fl-foo.baz-443",
"name": "fl-foo.baz-443",
"properties": {
"frontendIPConfiguration": {
"id": "--front-end-ip-id-1--"
},
"frontendPort": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/frontendPorts/fp-443"
},
"hostName": "foo.baz",
"protocol": "Https",
"sslCertificate": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/sslCertificates/--namespace-----the-name-of-the-secret--"
}
}
},
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/httpListeners/fl-foo.baz-80",
"name": "fl-foo.baz-80",
"properties": {
"frontendIPConfiguration": {
"id": "--front-end-ip-id-1--"
},
"frontendPort": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/frontendPorts/fp-80"
},
"hostName": "foo.baz",
"protocol": "Http"
}
}
],
"probes": [
{
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/probes/defaultprobe-Http",
"name": "defaultprobe-Http",
"properties": {
"host": "localhost",
"interval": 30,
"path": "/",
"protocol": "Http",
"timeout": 30,
"unhealthyThreshold": 3
}
},
{
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/probes/defaultprobe-Https",
"name": "defaultprobe-Https",
"properties": {
"host": "localhost",
"interval": 30,
"path": "/",
"protocol": "Https",
"timeout": 30,
"unhealthyThreshold": 3
}
},
{
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/probes/pb---namespace---hello-world-80---name--",
"name": "pb---namespace---hello-world-80---name--",
"properties": {
"host": "foo.baz",
"interval": 30,
"path": "/",
"protocol": "Http",
"timeout": 30,
"unhealthyThreshold": 3
}
}
],
"redirectConfigurations": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/redirectConfigurations/sslr-fl-foo.baz-443",
"name": "sslr-fl-foo.baz-443",
"properties": {
"includePath": true,
"includeQueryString": true,
"redirectType": "Permanent",
"targetListener": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/httpListeners/fl-foo.baz-443"
}
}
}
],
"requestRoutingRules": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/requestRoutingRules/rr-foo.baz-443",
"name": "rr-foo.baz-443",
"properties": {
"backendAddressPool": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendAddressPools/pool---namespace---hello-world-80-bp-80"
},
"backendHttpSettings": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/backendHttpSettingsCollection/bp---namespace---hello-world-80-80---name--"
},
"httpListener": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/httpListeners/fl-foo.baz-443"
},
"ruleType": "Basic"
}
},
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/requestRoutingRules/rr-foo.baz-80",
"name": "rr-foo.baz-80",
"properties": {
"httpListener": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/httpListeners/fl-foo.baz-80"
},
"redirectConfiguration": {
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/redirectConfigurations/sslr-fl-foo.baz-443"
},
"ruleType": "Basic"
}
}
],
"sku": {
"capacity": 3,
"name": "Standard_v2",
"tier": "Standard_v2"
},
"sslCertificates": [
{
"etag": "*",
"id": "/subscriptions/--subscription--/resourceGroups/--resource-group--/providers/Microsoft.Network/applicationGateways/--app-gw-name--/sslCertificates/--namespace-----the-name-of-the-secret--",
"name": "--namespace-----the-name-of-the-secret--",
"properties": {
"data": "xx",
"password": "msazure"
}
}
],
"urlPathMaps": null
},
"tags": {
"ingress-for-aks-cluster-id": "/subscriptions/subid/resourcegroups/aksresgp/providers/Microsoft.ContainerService/managedClusters/aksname",
"last-updated-by-k8s-ingress": "2009-11-17 20:34:58.651387237 +0000 UTC",
"managed-by-k8s-ingress": "a/b/c"
}
}
19 changes: 19 additions & 0 deletions functional_tests/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/tests/mocks"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/utils"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/version"
"github.com/Azure/application-gateway-kubernetes-ingress/pkg/tests/fixtures"
)

func TestFunctional(t *testing.T) {
Expand Down Expand Up @@ -522,5 +523,23 @@ var _ = ginkgo.Describe("Tests `appgw.ConfigBuilder`", func() {
check(cbCtx, "two_ingresses_same_domain_tls_notls.json", stopChannel, ctxt, configBuilder)
})

ginkgo.It("Preexisting port w/ same port number", func() {

cbCtx := &ConfigBuilderContext{
IngressList: []*v1beta1.Ingress{
ingress,
},
ServiceList: serviceList,
EnvVariables: environment.GetFakeEnv(),
DefaultAddressPoolID: to.StringPtr("xx"),
DefaultHTTPSettingsID: to.StringPtr("yyxx"),
ExistingPortsByNumber: map[Port]n.ApplicationGatewayFrontendPort{
Port(80): fixtures.GetDefaultPort(),
Port(8989): fixtures.GetPort(8989),
},
}
check(cbCtx, "duplicate_ports.json", stopChannel, ctxt, configBuilder)
})

})
})
1 change: 0 additions & 1 deletion pkg/appgw/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
// Clock is an interface, which allows you to implement your own Time.
type Clock interface {
Now() time.Time

}

// ConfigBuilder is a builder for application gateway configuration
Expand Down
Loading

0 comments on commit cccb76c

Please sign in to comment.