Browse code

Revert "Add router support for wildcard domains (*.foo.com)"

Clayton Coleman authored on 2016/10/22 08:37:48
Showing 18 changed files
... ...
@@ -19753,10 +19753,6 @@ _openshift_infra_f5-router()
19753 19753
     flags_with_completion=()
19754 19754
     flags_completion=()
19755 19755
 
19756
-    flags+=("--allow-wildcard-routes")
19757
-    local_nonpersistent_flags+=("--allow-wildcard-routes")
19758
-    flags+=("--allowed-domains=")
19759
-    local_nonpersistent_flags+=("--allowed-domains=")
19760 19756
     flags+=("--as=")
19761 19757
     local_nonpersistent_flags+=("--as=")
19762 19758
     flags+=("--certificate-authority=")
... ...
@@ -19779,8 +19775,6 @@ _openshift_infra_f5-router()
19779 19779
     local_nonpersistent_flags+=("--config=")
19780 19780
     flags+=("--context=")
19781 19781
     local_nonpersistent_flags+=("--context=")
19782
-    flags+=("--denied-domains=")
19783
-    local_nonpersistent_flags+=("--denied-domains=")
19784 19782
     flags+=("--f5-host=")
19785 19783
     local_nonpersistent_flags+=("--f5-host=")
19786 19784
     flags+=("--f5-http-vserver=")
... ...
@@ -19896,10 +19890,6 @@ _openshift_infra_router()
19896 19896
     flags_with_completion=()
19897 19897
     flags_completion=()
19898 19898
 
19899
-    flags+=("--allow-wildcard-routes")
19900
-    local_nonpersistent_flags+=("--allow-wildcard-routes")
19901
-    flags+=("--allowed-domains=")
19902
-    local_nonpersistent_flags+=("--allowed-domains=")
19903 19899
     flags+=("--as=")
19904 19900
     local_nonpersistent_flags+=("--as=")
19905 19901
     flags+=("--certificate-authority=")
... ...
@@ -19928,8 +19918,6 @@ _openshift_infra_router()
19928 19928
     local_nonpersistent_flags+=("--default-certificate-dir=")
19929 19929
     flags+=("--default-certificate-path=")
19930 19930
     local_nonpersistent_flags+=("--default-certificate-path=")
19931
-    flags+=("--denied-domains=")
19932
-    local_nonpersistent_flags+=("--denied-domains=")
19933 19931
     flags+=("--extended-validation")
19934 19932
     local_nonpersistent_flags+=("--extended-validation")
19935 19933
     flags+=("--fields=")
... ...
@@ -19914,10 +19914,6 @@ _openshift_infra_f5-router()
19914 19914
     flags_with_completion=()
19915 19915
     flags_completion=()
19916 19916
 
19917
-    flags+=("--allow-wildcard-routes")
19918
-    local_nonpersistent_flags+=("--allow-wildcard-routes")
19919
-    flags+=("--allowed-domains=")
19920
-    local_nonpersistent_flags+=("--allowed-domains=")
19921 19917
     flags+=("--as=")
19922 19918
     local_nonpersistent_flags+=("--as=")
19923 19919
     flags+=("--certificate-authority=")
... ...
@@ -19940,8 +19936,6 @@ _openshift_infra_f5-router()
19940 19940
     local_nonpersistent_flags+=("--config=")
19941 19941
     flags+=("--context=")
19942 19942
     local_nonpersistent_flags+=("--context=")
19943
-    flags+=("--denied-domains=")
19944
-    local_nonpersistent_flags+=("--denied-domains=")
19945 19943
     flags+=("--f5-host=")
19946 19944
     local_nonpersistent_flags+=("--f5-host=")
19947 19945
     flags+=("--f5-http-vserver=")
... ...
@@ -20057,10 +20051,6 @@ _openshift_infra_router()
20057 20057
     flags_with_completion=()
20058 20058
     flags_completion=()
20059 20059
 
20060
-    flags+=("--allow-wildcard-routes")
20061
-    local_nonpersistent_flags+=("--allow-wildcard-routes")
20062
-    flags+=("--allowed-domains=")
20063
-    local_nonpersistent_flags+=("--allowed-domains=")
20064 20060
     flags+=("--as=")
20065 20061
     local_nonpersistent_flags+=("--as=")
20066 20062
     flags+=("--certificate-authority=")
... ...
@@ -20089,8 +20079,6 @@ _openshift_infra_router()
20089 20089
     local_nonpersistent_flags+=("--default-certificate-dir=")
20090 20090
     flags+=("--default-certificate-path=")
20091 20091
     local_nonpersistent_flags+=("--default-certificate-path=")
20092
-    flags+=("--denied-domains=")
20093
-    local_nonpersistent_flags+=("--denied-domains=")
20094 20092
     flags+=("--extended-validation")
20095 20093
     local_nonpersistent_flags+=("--extended-validation")
20096 20094
     flags+=("--fields=")
... ...
@@ -24,14 +24,6 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
24 24
 
25 25
 .SH OPTIONS
26 26
 .PP
27
-\fB\-\-allow\-wildcard\-routes\fP=false
28
-    Allow wildcard host names for routes
29
-
30
-.PP
31
-\fB\-\-allowed\-domains\fP=[]
32
-    List of comma separated domains to allow in routes. If specified, only the domains in this list will be allowed routes. Note that domains in the denied list take precedence over the ones in the allowed list
33
-
34
-.PP
35 27
 \fB\-\-api\-version\fP=""
36 28
     DEPRECATED: The API version to use when talking to the server
37 29
 
... ...
@@ -64,10 +56,6 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
64 64
     The name of the kubeconfig context to use
65 65
 
66 66
 .PP
67
-\fB\-\-denied\-domains\fP=[]
68
-    List of comma separated domains to deny in routes
69
-
70
-.PP
71 67
 \fB\-\-f5\-host\fP=""
72 68
     The host of F5 BIG\-IP's management interface
73 69
 
... ...
@@ -30,14 +30,6 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
30 30
 
31 31
 .SH OPTIONS
32 32
 .PP
33
-\fB\-\-allow\-wildcard\-routes\fP=false
34
-    Allow wildcard host names for routes
35
-
36
-.PP
37
-\fB\-\-allowed\-domains\fP=[]
38
-    List of comma separated domains to allow in routes. If specified, only the domains in this list will be allowed routes. Note that domains in the denied list take precedence over the ones in the allowed list
39
-
40
-.PP
41 33
 \fB\-\-api\-version\fP=""
42 34
     DEPRECATED: The API version to use when talking to the server
43 35
 
... ...
@@ -82,10 +74,6 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
82 82
     A path to default certificate to use for routes that don't expose a TLS server cert; in PEM format
83 83
 
84 84
 .PP
85
-\fB\-\-denied\-domains\fP=[]
86
-    List of comma separated domains to deny in routes
87
-
88
-.PP
89 85
 \fB\-\-extended\-validation\fP=true
90 86
     If set, then an additional extended validation step is performed on all routes admitted in by this router. Defaults to true and enables the extended validation checks.
91 87
 
... ...
@@ -16,7 +16,7 @@ RUN INSTALL_PKGS="haproxy" && \
16 16
     yum clean all && \
17 17
     mkdir -p /var/lib/haproxy/router/{certs,cacerts} && \
18 18
     mkdir -p /var/lib/haproxy/{conf,run,bin,log} && \
19
-    touch /var/lib/haproxy/conf/{{os_http_be,os_edge_http_be,os_tcp_be,os_sni_passthrough,os_reencrypt,os_edge_http_expose,os_edge_http_redirect,cert_config,os_wildcard_domain}.map,haproxy.config} && \
19
+    touch /var/lib/haproxy/conf/{{os_http_be,os_edge_http_be,os_tcp_be,os_sni_passthrough,os_reencrypt,os_edge_http_expose,os_edge_http_redirect,cert_config}.map,haproxy.config} && \
20 20
     chmod -R 777 /var && \
21 21
     setcap 'cap_net_bind_service=ep' /usr/sbin/haproxy
22 22
 
... ...
@@ -109,36 +109,15 @@ frontend public
109 109
   acl secure_redirect base,map_beg(/var/lib/haproxy/conf/os_edge_http_redirect.map) -m found
110 110
   redirect scheme https if secure_redirect
111 111
 
112
-{{ if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
113
-  #  Check for wildcard domains with redirected http routes.
114
-  acl wildcard_domain hdr(host),map_reg(/var/lib/haproxy/conf/os_wildcard_domain.map) -m found
115
-
116
-  acl wildcard_secure_redirect base,map_reg(/var/lib/haproxy/conf/os_edge_http_redirect.map) -m found
117
-  redirect scheme https if wildcard_domain wildcard_secure_redirect
118
-
119
-{{ end }}
120
-
121 112
   # Check if it is an edge route exposed insecurely.
122 113
   acl edge_http_expose base,map_beg(/var/lib/haproxy/conf/os_edge_http_expose.map) -m found
123 114
   use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_expose.map)] if edge_http_expose
124 115
 
125 116
   # map to http backend
126 117
   # Search from most specific to general path (host case).
127
-  acl http_backend base,map_beg(/var/lib/haproxy/conf/os_http_be.map) -m found
128
-  use_backend be_http_%[base,map_beg(/var/lib/haproxy/conf/os_http_be.map)] if http_backend
129
-
130
-{{ if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
131
-  #  Check for wildcard domains with exposed http routes.
132
-  acl wildcard_edge_http_expose base,map_reg(/var/lib/haproxy/conf/os_edge_http_expose.map) -m found
133
-  use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_expose.map)] if wildcard_domain wildcard_edge_http_expose
134
-
135
-  # map to http backend
136
-  # Search from most specific to general path (host case).
137 118
   # Note: If no match, haproxy uses the default_backend, no other
138 119
   #       use_backend directives below this will be processed.
139
-  use_backend be_http_%[base,map_reg(/var/lib/haproxy/conf/os_http_be.map)] if wildcard_domain
140
-
141
-{{ end }}
120
+  use_backend be_http_%[base,map_beg(/var/lib/haproxy/conf/os_http_be.map)]
142 121
 
143 122
   default_backend openshift_default
144 123
 
... ...
@@ -155,15 +134,6 @@ frontend public_ssl
155 155
   acl sni_passthrough req.ssl_sni,map(/var/lib/haproxy/conf/os_sni_passthrough.map) -m found
156 156
   use_backend be_tcp_%[req.ssl_sni,map(/var/lib/haproxy/conf/os_tcp_be.map)] if sni sni_passthrough
157 157
 
158
-{{ if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
159
-  #  Check for wildcard domains with passthrough.
160
-  acl sni_wildcard_domain req.ssl_sni,map_reg(/var/lib/haproxy/conf/os_wildcard_domain.map) -m found
161
-
162
-  acl sni_wildcard_passthrough req.ssl_sni,map_reg(/var/lib/haproxy/conf/os_sni_passthrough.map) -m found
163
-  use_backend be_tcp_%[req.ssl_sni,map_reg(/var/lib/haproxy/conf/os_tcp_be.map)] if sni sni_wildcard_domain sni_wildcard_passthrough
164
-
165
-{{ end }}
166
-
167 158
   # if the route is SNI and NOT passthrough enter the termination flow
168 159
   use_backend be_sni if sni
169 160
 
... ...
@@ -201,23 +171,9 @@ frontend fe_sni
201 201
 
202 202
   # map to http backend
203 203
   # Search from most specific to general path (host case).
204
-  acl http_backend base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map) -m found
205
-  use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map)] if http_backend
206
-
207
-{{ if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
208
-  #  Check for wildcard domains with redirected or exposed http routes.
209
-  acl sni_wildcard_domain hdr(host),map_reg(/var/lib/haproxy/conf/os_wildcard_domain.map) -m found
210
-
211
-  acl wildcard_reencrypt base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map) -m found
212
-  use_backend be_secure_%[base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map)] if sni_wildcard_domain wildcard_reencrypt
213
-
214
-  # map to http backend
215
-  # Search from most specific to general path (host case).
216 204
   # Note: If no match, haproxy uses the default_backend, no other
217 205
   #       use_backend directives below this will be processed.
218
-  use_backend be_edge_http_%[base,map_reg(/var/lib/haproxy/conf/os_edge_http_be.map)] if sni_wildcard_domain
219
-
220
-{{ end }}
206
+  use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map)]
221 207
 
222 208
   default_backend openshift_default
223 209
 
... ...
@@ -252,22 +208,9 @@ frontend fe_no_sni
252 252
 
253 253
   # map to http backend
254 254
   # Search from most specific to general path (host case).
255
-  acl edge_http_backend base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map) -m found
256
-  use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map)] if edge_http_backend
257
-
258
-{{ if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
259
-  acl host_wildcard_domain req.ssl_sni,map_reg(/var/lib/haproxy/conf/os_wildcard_domain.map) -m found
260
-
261
-  acl host_reencrypt base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map) -m found
262
-  use_backend be_secure_%[base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map)] if host_wildcard_domain host_reencrypt
263
-
264
-  # map to http backend
265
-  # Search from most specific to general path (host case).
266 255
   # Note: If no match, haproxy uses the default_backend, no other
267 256
   #       use_backend directives below this will be processed.
268
-  use_backend be_edge_http_%[base,map_reg(/var/lib/haproxy/conf/os_edge_http_be.map)] if host_wildcard_domain
269
-
270
-{{ end }}
257
+  use_backend be_edge_http_%[base,map_beg(/var/lib/haproxy/conf/os_edge_http_be.map)]
271 258
 
272 259
   default_backend openshift_default
273 260
 
... ...
@@ -387,8 +330,8 @@ backend be_edge_http_{{$cfgIdx}}
387 387
     {{ end }}{{/* end iterate over services */}}
388 388
   {{ end }}{{/* end if tls==edge/none */}}
389 389
 
390
-  {{ if eq $cfg.TLSTermination "passthrough" }}
391 390
 # Secure backend, pass through
391
+  {{ if eq $cfg.TLSTermination "passthrough" }}
392 392
 backend be_tcp_{{$cfgIdx}}
393 393
 {{ if ne (env "ROUTER_SYSLOG_ADDRESS" "") ""}}
394 394
   option tcplog
... ...
@@ -451,8 +394,8 @@ backend be_tcp_{{$cfgIdx}}
451 451
     {{ end }}{{/* end iterate over services*/}}
452 452
   {{ end }}{{/*end tls==passthrough*/}}
453 453
 
454
-  {{ if eq $cfg.TLSTermination "reencrypt" }}
455 454
 # Secure backend which requires re-encryption
455
+  {{ if eq $cfg.TLSTermination "reencrypt" }}
456 456
 backend be_secure_{{$cfgIdx}}
457 457
   mode http
458 458
   option redispatch
... ...
@@ -529,34 +472,13 @@ backend be_secure_{{$cfgIdx}}
529 529
 
530 530
 {{/*--------------------------------- END OF HAPROXY CONFIG, BELOW ARE MAPPING FILES ------------------------*/}}
531 531
 {{/*
532
-    os_wildcard_domain.map: contains a mapping of wildcard hosts for a
533
-			[sub]domain regexps. This map is used to check if
534
-			a host matches a [sub]domain with has wildcard support.
535
-*/}}
536
-{{ define "/var/lib/haproxy/conf/os_wildcard_domain.map" }}
537
-{{     if matchPattern "true|TRUE" (env "ROUTER_ALLOW_WILDCARD_ROUTES" "")}}
538
-{{       range $idx, $cfg := .State }}
539
-{{         if ne $cfg.Host ""}}
540
-{{           if $cfg.IsWildcard }}
541
-{{genDomainWildcardRegexp $cfg.Host "" true}} 1
542
-{{           end }}
543
-{{         end }}
544
-{{       end }}
545
-{{     end }}{{/* end if router allows wildcard routes */}}
546
-{{ end }}{{/* end wildcard domain map template */}}
547
-
548
-{{/*
549 532
     os_http_be.map: contains a mapping of www.example.com -> <service name>.  This map is used to discover the correct backend
550 533
                         by attaching a prefix (be_http_) by use_backend statements if acls are matched.
551 534
 */}}
552 535
 {{ define "/var/lib/haproxy/conf/os_http_be.map" }}
553 536
 {{     range $idx, $cfg := .State }}
554 537
 {{       if and (ne $cfg.Host "") (eq $cfg.TLSTermination "")}}
555
-{{         if $cfg.IsWildcard }}
556
-{{genDomainWildcardRegexp $cfg.Host $cfg.Path false}} {{$idx}}
557
-{{         else }}
558 538
 {{$cfg.Host}}{{$cfg.Path}} {{$idx}}
559
-{{         end }}
560 539
 {{       end }}
561 540
 {{     end }}
562 541
 {{ end }}{{/* end http host map template */}}
... ...
@@ -568,11 +490,7 @@ backend be_secure_{{$cfgIdx}}
568 568
 {{ define "/var/lib/haproxy/conf/os_edge_http_be.map" }}
569 569
 {{     range $idx, $cfg := .State }}
570 570
 {{       if and (ne $cfg.Host "") (eq $cfg.TLSTermination "edge")}}
571
-{{         if $cfg.IsWildcard }}
572
-{{genDomainWildcardRegexp $cfg.Host $cfg.Path false}} {{$idx}}
573
-{{         else }}
574 571
 {{$cfg.Host}}{{$cfg.Path}} {{$idx}}
575
-{{         end }}
576 572
 {{       end }}
577 573
 {{     end }}
578 574
 {{ end }}{{/* end edge http host map template */}}
... ...
@@ -585,11 +503,7 @@ backend be_secure_{{$cfgIdx}}
585 585
 {{ define "/var/lib/haproxy/conf/os_edge_http_expose.map" }}
586 586
 {{     range $idx, $cfg := .State }}
587 587
 {{       if and (ne $cfg.Host "") (and (eq $cfg.TLSTermination "edge") (eq $cfg.InsecureEdgeTerminationPolicy "Allow"))}}
588
-{{         if $cfg.IsWildcard }}
589
-{{genDomainWildcardRegexp $cfg.Host $cfg.Path false}} {{$idx}}
590
-{{         else }}
591 588
 {{$cfg.Host}}{{$cfg.Path}} {{$idx}}
592
-{{         end }}
593 589
 {{       end }}
594 590
 {{     end }}
595 591
 {{ end }}{{/* end edge insecure expose http host map template */}}
... ...
@@ -602,11 +516,7 @@ backend be_secure_{{$cfgIdx}}
602 602
 {{ define "/var/lib/haproxy/conf/os_edge_http_redirect.map" }}
603 603
 {{     range $idx, $cfg := .State }}
604 604
 {{       if and (ne $cfg.Host "") (and (eq $cfg.TLSTermination "edge") (eq $cfg.InsecureEdgeTerminationPolicy "Redirect"))}}
605
-{{         if $cfg.IsWildcard }}
606
-{{genDomainWildcardRegexp $cfg.Host $cfg.Path false}} {{$idx}}
607
-{{         else }}
608 605
 {{$cfg.Host}}{{$cfg.Path}} {{$idx}}
609
-{{         end }}
610 606
 {{       end }}
611 607
 {{     end }}
612 608
 {{ end }}{{/* end edge insecure redirect http host map template */}}
... ...
@@ -619,11 +529,7 @@ backend be_secure_{{$cfgIdx}}
619 619
 {{ define "/var/lib/haproxy/conf/os_tcp_be.map" }}
620 620
 {{     range $idx, $cfg := .State }}
621 621
 {{       if and (eq $cfg.Path "") (and (ne $cfg.Host "") (or (eq $cfg.TLSTermination "passthrough") (eq $cfg.TLSTermination "reencrypt"))) }}
622
-{{         if $cfg.IsWildcard }}
623
-{{genDomainWildcardRegexp $cfg.Host "" true}} {{$idx}}
624
-{{         else }}
625 622
 {{$cfg.Host}} {{$idx}}
626
-{{         end }}
627 623
 {{       end }}
628 624
 {{     end }}
629 625
 {{ end }}{{/* end tcp host map template */}}
... ...
@@ -635,11 +541,7 @@ backend be_secure_{{$cfgIdx}}
635 635
 {{ define "/var/lib/haproxy/conf/os_sni_passthrough.map" }}
636 636
 {{     range $idx, $cfg := .State }}
637 637
 {{       if and (eq $cfg.Path "") (eq $cfg.TLSTermination "passthrough") }}
638
-{{         if $cfg.IsWildcard }}
639
-{{genDomainWildcardRegexp $cfg.Host "" true}} {{$idx}}
640
-{{         else }}
641 638
 {{$cfg.Host}} 1
642
-{{         end }}
643 639
 {{       end }}
644 640
 {{     end }}
645 641
 {{ end }}{{/* end sni passthrough map template */}}
... ...
@@ -652,11 +554,7 @@ backend be_secure_{{$cfgIdx}}
652 652
 {{ define "/var/lib/haproxy/conf/os_reencrypt.map" }}
653 653
 {{     range $idx, $cfg := .State }}
654 654
 {{       if and (ne $cfg.Host "") (eq $cfg.TLSTermination "reencrypt") }}
655
-{{         if $cfg.IsWildcard }}
656
-{{genDomainWildcardRegexp $cfg.Host $cfg.Path false}} {{$idx}}
657
-{{         else }}
658 655
 {{$cfg.Host}}{{$cfg.Path}} {{$idx}}
659
-{{         end }}
660 656
 {{       end }}
661 657
 {{     end }}
662 658
 {{ end }}{{/* end reencrypt map template */}}
... ...
@@ -15,7 +15,6 @@ import (
15 15
 	"github.com/openshift/origin/pkg/cmd/templates"
16 16
 	"github.com/openshift/origin/pkg/cmd/util"
17 17
 	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
18
-	routeapi "github.com/openshift/origin/pkg/route/api"
19 18
 	"github.com/openshift/origin/pkg/router/controller"
20 19
 	f5plugin "github.com/openshift/origin/pkg/router/f5"
21 20
 )
... ...
@@ -156,23 +155,6 @@ func (o *F5RouterOptions) Validate() error {
156 156
 	return o.F5Router.Validate()
157 157
 }
158 158
 
159
-// F5RouteAdmitterFunc returns a func that checks if a route is a
160
-// wildcard route and currently denies it.
161
-func (o *F5RouterOptions) F5RouteAdmitterFunc() controller.RouteAdmissionFunc {
162
-	return func(route *routeapi.Route) error {
163
-		if err := o.AdmissionCheck(route); err != nil {
164
-			return err
165
-		}
166
-
167
-		if _, wildcard := routeapi.NormalizeWildcardHost(route.Spec.Host); wildcard {
168
-			// TODO: F5 wildcard route support.
169
-			return fmt.Errorf("Wildcard routes are currently not supported by the F5 router")
170
-		}
171
-
172
-		return nil
173
-	}
174
-}
175
-
176 159
 // Run launches an F5 route sync process using the provided options. It never exits.
177 160
 func (o *F5RouterOptions) Run() error {
178 161
 	cfg := f5plugin.F5PluginConfig{
... ...
@@ -196,8 +178,7 @@ func (o *F5RouterOptions) Run() error {
196 196
 	}
197 197
 
198 198
 	statusPlugin := controller.NewStatusAdmitter(f5Plugin, oc, o.RouterName)
199
-	uniqueHostPlugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), statusPlugin)
200
-	plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.F5RouteAdmitterFunc(), false, statusPlugin)
199
+	plugin := controller.NewUniqueHost(statusPlugin, o.RouteSelectionFunc(), statusPlugin)
201 200
 
202 201
 	factory := o.RouterSelection.NewFactory(oc, kc)
203 202
 	controller := factory.Create(plugin)
... ...
@@ -43,15 +43,6 @@ type RouterSelection struct {
43 43
 	ProjectLabels        labels.Selector
44 44
 
45 45
 	IncludeUDP bool
46
-
47
-	DeniedDomains      []string
48
-	BlacklistedDomains sets.String
49
-
50
-	AllowedDomains     []string
51
-	WhitelistedDomains sets.String
52
-
53
-	AllowWildcardRoutes        bool
54
-	RestrictSubdomainOwnership bool
55 46
 }
56 47
 
57 48
 // Bind sets the appropriate labels
... ...
@@ -64,9 +55,6 @@ func (o *RouterSelection) Bind(flag *pflag.FlagSet) {
64 64
 	flag.StringVar(&o.ProjectLabelSelector, "project-labels", cmdutil.Env("PROJECT_LABELS", ""), "A label selector to apply to projects to watch; if '*' watches all projects the client can access")
65 65
 	flag.StringVar(&o.NamespaceLabelSelector, "namespace-labels", cmdutil.Env("NAMESPACE_LABELS", ""), "A label selector to apply to namespaces to watch")
66 66
 	flag.BoolVar(&o.IncludeUDP, "include-udp-endpoints", false, "If true, UDP endpoints will be considered as candidates for routing")
67
-	flag.StringSliceVar(&o.DeniedDomains, "denied-domains", envVarAsStrings("ROUTER_DENIED_DOMAINS", "", ","), "List of comma separated domains to deny in routes")
68
-	flag.StringSliceVar(&o.AllowedDomains, "allowed-domains", envVarAsStrings("ROUTER_ALLOWED_DOMAINS", "", ","), "List of comma separated domains to allow in routes. If specified, only the domains in this list will be allowed routes. Note that domains in the denied list take precedence over the ones in the allowed list")
69
-	flag.BoolVar(&o.AllowWildcardRoutes, "allow-wildcard-routes", cmdutil.Env("ROUTER_ALLOW_WILDCARD_ROUTES", "") == "true", "Allow wildcard host names for routes")
70 67
 }
71 68
 
72 69
 // RouteSelectionFunc returns a func that identifies the host for a route.
... ...
@@ -95,50 +83,6 @@ func (o *RouterSelection) RouteSelectionFunc() controller.RouteHostFunc {
95 95
 	}
96 96
 }
97 97
 
98
-func (o *RouterSelection) AdmissionCheck(route *routeapi.Route) error {
99
-	if len(route.Spec.Host) < 1 {
100
-		return nil
101
-	}
102
-
103
-	if hostInDomainList(route.Spec.Host, o.BlacklistedDomains) {
104
-		glog.V(4).Infof("host %s in list of denied domains", route.Spec.Host)
105
-		return fmt.Errorf("host in list of denied domains")
106
-	}
107
-
108
-	if o.WhitelistedDomains.Len() > 0 {
109
-		glog.V(4).Infof("Checking if host %s is in the list of allowed domains", route.Spec.Host)
110
-		if hostInDomainList(route.Spec.Host, o.WhitelistedDomains) {
111
-			glog.V(4).Infof("host %s admitted - in the list of allowed domains", route.Spec.Host)
112
-			return nil
113
-		}
114
-
115
-		glog.V(4).Infof("host %s rejected - not in the list of allowed domains", route.Spec.Host)
116
-		return fmt.Errorf("host not in the allowed list of domains")
117
-	}
118
-
119
-	glog.V(4).Infof("host %s admitted", route.Spec.Host)
120
-	return nil
121
-}
122
-
123
-// RouteAdmissionFunc returns a func that checks if a route can be admitted
124
-// based on blacklist & whitelist checks and wildcard routes policy setting.
125
-// Note: The blacklist settings trumps the whitelist ones.
126
-func (o *RouterSelection) RouteAdmissionFunc() controller.RouteAdmissionFunc {
127
-	return func(route *routeapi.Route) error {
128
-		if err := o.AdmissionCheck(route); err != nil {
129
-			return err
130
-		}
131
-
132
-		if _, wildcard := routeapi.NormalizeWildcardHost(route.Spec.Host); wildcard {
133
-			if !o.AllowWildcardRoutes {
134
-				return fmt.Errorf("wildcard routes are not allowed")
135
-			}
136
-		}
137
-
138
-		return nil
139
-	}
140
-}
141
-
142 98
 // Complete converts string representations of field and label selectors to their parsed equivalent, or
143 99
 // returns an error.
144 100
 func (o *RouterSelection) Complete() error {
... ...
@@ -194,13 +138,6 @@ func (o *RouterSelection) Complete() error {
194 194
 		}
195 195
 		o.NamespaceLabels = s
196 196
 	}
197
-
198
-	o.BlacklistedDomains = sets.NewString(o.DeniedDomains...)
199
-	o.WhitelistedDomains = sets.NewString(o.AllowedDomains...)
200
-
201
-	// Restrict subdomains is currently enforced for wildcard routes.
202
-	o.RestrictSubdomainOwnership = o.AllowWildcardRoutes
203
-
204 197
 	return nil
205 198
 }
206 199
 
... ...
@@ -261,28 +198,3 @@ func (n namespaceNames) NamespaceNames() (sets.String, error) {
261 261
 	}
262 262
 	return names, nil
263 263
 }
264
-
265
-func envVarAsStrings(name, defaultValue, seperator string) []string {
266
-	strlist := []string{}
267
-	if env := cmdutil.Env(name, defaultValue); env != "" {
268
-		values := strings.Split(env, seperator)
269
-		for i := range values {
270
-			if val := strings.TrimSpace(values[i]); val != "" {
271
-				strlist = append(strlist, val)
272
-			}
273
-		}
274
-	}
275
-	return strlist
276
-}
277
-
278
-func hostInDomainList(host string, domains sets.String) bool {
279
-	if domains.Has(host) {
280
-		return true
281
-	}
282
-
283
-	if idx := strings.IndexRune(host, '.'); idx > 0 {
284
-		return hostInDomainList(host[idx+1:], domains)
285
-	}
286
-
287
-	return false
288
-}
... ...
@@ -207,8 +207,7 @@ func (o *TemplateRouterOptions) Run() error {
207 207
 	if o.ExtendedValidation {
208 208
 		nextPlugin = controller.NewExtendedValidator(nextPlugin, controller.RejectionRecorder(statusPlugin))
209 209
 	}
210
-	uniqueHostPlugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), controller.RejectionRecorder(statusPlugin))
211
-	plugin := controller.NewHostAdmitter(uniqueHostPlugin, o.RouteAdmissionFunc(), o.RestrictSubdomainOwnership, controller.RejectionRecorder(statusPlugin))
210
+	plugin := controller.NewUniqueHost(nextPlugin, o.RouteSelectionFunc(), controller.RejectionRecorder(statusPlugin))
212 211
 
213 212
 	factory := o.RouterSelection.NewFactory(oc, kc)
214 213
 	controller := factory.Create(plugin)
... ...
@@ -1,15 +1,9 @@
1 1
 package api
2 2
 
3 3
 import (
4
-	"strings"
5
-
6 4
 	kapi "k8s.io/kubernetes/pkg/api"
7 5
 )
8 6
 
9
-const (
10
-	RouteWildcardPrefix = "*."
11
-)
12
-
13 7
 // IngressConditionStatus returns the first status and condition matching the provided ingress condition type. Conditions
14 8
 // prefer the first matching entry and clients are allowed to ignore later conditions of the same type.
15 9
 func IngressConditionStatus(ingress *RouteIngress, t RouteIngressConditionType) (kapi.ConditionStatus, RouteIngressCondition) {
... ...
@@ -26,29 +20,11 @@ func RouteLessThan(route1, route2 *Route) bool {
26 26
 	if route1.CreationTimestamp.Before(route2.CreationTimestamp) {
27 27
 		return true
28 28
 	}
29
-
30
-	if route1.CreationTimestamp == route2.CreationTimestamp {
31
-		if route1.UID < route2.UID {
32
-			return true
33
-		}
34
-		if route1.Namespace < route2.Namespace {
35
-			return true
36
-		}
37
-		return route1.Name < route2.Name
29
+	if route1.CreationTimestamp == route2.CreationTimestamp && route1.UID < route2.UID {
30
+		return true
38 31
 	}
39
-
40
-	return false
41
-}
42
-
43
-// NormalizeWildcardHost tests if a host is wildcarded and returns
44
-// the "normalized" (domain name currently) form of the host.
45
-func NormalizeWildcardHost(host string) (string, bool) {
46
-	if len(host) > 0 {
47
-		if strings.HasPrefix(host, RouteWildcardPrefix) {
48
-			// For wildcard hosts, strip the prefix.
49
-			return host[len(RouteWildcardPrefix):], true
50
-		}
32
+	if route1.Namespace < route2.Namespace {
33
+		return true
51 34
 	}
52
-
53
-	return host, false
35
+	return route1.Name < route2.Name
54 36
 }
... ...
@@ -9,12 +9,9 @@ import (
9 9
 )
10 10
 
11 11
 func TestRouteLessThan(t *testing.T) {
12
-	current := unversioned.Now()
13
-	older := unversioned.Time{Time: current.Add(-1 * time.Minute)}
14
-
15 12
 	r := Route{
16 13
 		ObjectMeta: kapi.ObjectMeta{
17
-			CreationTimestamp: current.Rfc3339Copy(),
14
+			CreationTimestamp: unversioned.Now().Rfc3339Copy(),
18 15
 			UID:               "alpha",
19 16
 			Namespace:         "alpha",
20 17
 			Name:              "alpha",
... ...
@@ -52,27 +49,6 @@ func TestRouteLessThan(t *testing.T) {
52 52
 				Name:              "beta",
53 53
 			},
54 54
 		}, true},
55
-		{Route{
56
-			ObjectMeta: kapi.ObjectMeta{
57
-				CreationTimestamp: older,
58
-				UID:               r.UID,
59
-				Namespace:         r.Namespace,
60
-				Name:              "beta",
61
-			},
62
-		}, false},
63
-		{Route{
64
-			ObjectMeta: kapi.ObjectMeta{
65
-				CreationTimestamp: older,
66
-				UID:               r.UID,
67
-				Name:              "gamma",
68
-			},
69
-		}, false},
70
-		{Route{
71
-			ObjectMeta: kapi.ObjectMeta{
72
-				CreationTimestamp: older,
73
-				Name:              "delta",
74
-			},
75
-		}, false},
76 55
 		{r, false},
77 56
 	}
78 57
 
... ...
@@ -88,53 +64,3 @@ func TestRouteLessThan(t *testing.T) {
88 88
 		}
89 89
 	}
90 90
 }
91
-
92
-func TestNormalizeWildcardHost(t *testing.T) {
93
-	tests := []struct {
94
-		name        string
95
-		host        string
96
-		expectation string
97
-		wildcard    bool
98
-	}{
99
-		{
100
-			name:        "plain",
101
-			host:        "www.host.test",
102
-			expectation: "www.host.test",
103
-			wildcard:    false,
104
-		},
105
-		{
106
-			name:        "aceswild",
107
-			host:        "*.aceswild.test",
108
-			expectation: "aceswild.test",
109
-			wildcard:    true,
110
-		},
111
-		{
112
-			name:        "otherwild",
113
-			host:        "aces.*.test",
114
-			expectation: "aces.*.test",
115
-			wildcard:    false,
116
-		},
117
-		{
118
-			name:        "Invalid host",
119
-			host:        "*.aces.*.test",
120
-			expectation: "aces.*.test",
121
-			wildcard:    true,
122
-		},
123
-		{
124
-			name:        "No host",
125
-			host:        "",
126
-			expectation: "",
127
-			wildcard:    false,
128
-		},
129
-	}
130
-
131
-	for _, tc := range tests {
132
-		host, flag := NormalizeWildcardHost(tc.host)
133
-
134
-		if flag != tc.wildcard {
135
-			t.Errorf("Test case %s expected %t got %t", tc.name, tc.wildcard, flag)
136
-		} else if host != tc.expectation {
137
-			t.Errorf("Test case %s expected %v got %v", tc.name, tc.expectation, host)
138
-		}
139
-	}
140
-}
... ...
@@ -26,8 +26,7 @@ func ValidateRoute(route *routeapi.Route) field.ErrorList {
26 26
 
27 27
 	//host is not required but if it is set ensure it meets DNS requirements
28 28
 	if len(route.Spec.Host) > 0 {
29
-		hostname, _ := routeapi.NormalizeWildcardHost(route.Spec.Host)
30
-		if len(kvalidation.IsDNS1123Subdomain(hostname)) != 0 {
29
+		if len(kvalidation.IsDNS1123Subdomain(route.Spec.Host)) != 0 {
31 30
 			result = append(result, field.Invalid(specPath.Child("host"), route.Spec.Host, "host must conform to DNS 952 subdomain conventions"))
32 31
 		}
33 32
 	}
... ...
@@ -182,34 +182,6 @@ func TestValidateRoute(t *testing.T) {
182 182
 			expectedErrors: 1,
183 183
 		},
184 184
 		{
185
-			name: "Wildcard host",
186
-			route: &api.Route{
187
-				ObjectMeta: kapi.ObjectMeta{
188
-					Name:      "name",
189
-					Namespace: "aceswild",
190
-				},
191
-				Spec: api.RouteSpec{
192
-					Host: "*.aceswild.com",
193
-					To:   createRouteSpecTo("serviceName", "Service"),
194
-				},
195
-			},
196
-			expectedErrors: 0,
197
-		},
198
-		{
199
-			name: "Invalid Wildcard host",
200
-			route: &api.Route{
201
-				ObjectMeta: kapi.ObjectMeta{
202
-					Name:      "name",
203
-					Namespace: "wildly",
204
-				},
205
-				Spec: api.RouteSpec{
206
-					Host: "*.not.*.wild.ly",
207
-					To:   createRouteSpecTo("serviceName", "Service"),
208
-				},
209
-			},
210
-			expectedErrors: 1,
211
-		},
212
-		{
213 185
 			name: "No service name",
214 186
 			route: &api.Route{
215 187
 				ObjectMeta: kapi.ObjectMeta{
... ...
@@ -1025,146 +997,3 @@ func TestExtendedValidateRoute(t *testing.T) {
1025 1025
 		}
1026 1026
 	}
1027 1027
 }
1028
-
1029
-func TestValidateRouteWildcard(t *testing.T) {
1030
-	tests := []struct {
1031
-		name             string
1032
-		route            *api.Route
1033
-		errorExpectation bool
1034
-	}{
1035
-		{
1036
-			name: "No Name",
1037
-			route: &api.Route{
1038
-				ObjectMeta: kapi.ObjectMeta{
1039
-					Namespace: "foo",
1040
-				},
1041
-				Spec: api.RouteSpec{
1042
-					Host: "host",
1043
-					To:   createRouteSpecTo("serviceName", "Service"),
1044
-				},
1045
-			},
1046
-			errorExpectation: false,
1047
-		},
1048
-		{
1049
-			name: "Named host",
1050
-			route: &api.Route{
1051
-				ObjectMeta: kapi.ObjectMeta{
1052
-					Name: "named",
1053
-				},
1054
-				Spec: api.RouteSpec{
1055
-					Host: "www.name.test",
1056
-					To:   createRouteSpecTo("serviceName", "Service"),
1057
-				},
1058
-			},
1059
-			errorExpectation: false,
1060
-		},
1061
-		{
1062
-			name: "aceswild",
1063
-			route: &api.Route{
1064
-				ObjectMeta: kapi.ObjectMeta{
1065
-					Name: "aceswild",
1066
-				},
1067
-				Spec: api.RouteSpec{
1068
-					Host: "*.aceswild.test",
1069
-					To:   createRouteSpecTo("serviceName", "Service"),
1070
-				},
1071
-			},
1072
-			errorExpectation: false,
1073
-		},
1074
-		{
1075
-			name: "another wild",
1076
-			route: &api.Route{
1077
-				ObjectMeta: kapi.ObjectMeta{
1078
-					Name: "anotherwild",
1079
-				},
1080
-				Spec: api.RouteSpec{
1081
-					Host: "*.where.the.wild.things.ar",
1082
-					To:   createRouteSpecTo("serviceName", "Service"),
1083
-				},
1084
-			},
1085
-			errorExpectation: false,
1086
-		},
1087
-		{
1088
-			name: "Invalid host",
1089
-			route: &api.Route{
1090
-				ObjectMeta: kapi.ObjectMeta{
1091
-					Name:      "invalid",
1092
-					Namespace: "foo",
1093
-				},
1094
-				Spec: api.RouteSpec{
1095
-					Host: "aces.*.test",
1096
-					To:   createRouteSpecTo("serviceName", "Service"),
1097
-				},
1098
-			},
1099
-			errorExpectation: true,
1100
-		},
1101
-		{
1102
-			name: "Bad wildcard host",
1103
-			route: &api.Route{
1104
-				ObjectMeta: kapi.ObjectMeta{
1105
-					Name:      "badwildcard",
1106
-					Namespace: "foo",
1107
-				},
1108
-				Spec: api.RouteSpec{
1109
-					Host: "*.aces.*.test",
1110
-					To:   createRouteSpecTo("serviceName", "Service"),
1111
-				},
1112
-			},
1113
-			errorExpectation: true,
1114
-		},
1115
-		{
1116
-			name: "Another bad wildcard host",
1117
-			route: &api.Route{
1118
-				ObjectMeta: kapi.ObjectMeta{
1119
-					Name:      "badwildcard2",
1120
-					Namespace: "foo",
1121
-				},
1122
-				Spec: api.RouteSpec{
1123
-					Host: "*aces.wild.test",
1124
-					To:   createRouteSpecTo("serviceName", "Service"),
1125
-				},
1126
-			},
1127
-			errorExpectation: true,
1128
-		},
1129
-		{
1130
-			name: "Yet another bad wildcard host",
1131
-			route: &api.Route{
1132
-				ObjectMeta: kapi.ObjectMeta{
1133
-					Name:      "badwildcard3",
1134
-					Namespace: "foo",
1135
-				},
1136
-				Spec: api.RouteSpec{
1137
-					Host: "aces*.wild.test",
1138
-					To:   createRouteSpecTo("serviceName", "Service"),
1139
-				},
1140
-			},
1141
-			errorExpectation: true,
1142
-		},
1143
-		{
1144
-			name: "And one more bad wildcard host",
1145
-			route: &api.Route{
1146
-				ObjectMeta: kapi.ObjectMeta{
1147
-					Name:      "badwildcard4",
1148
-					Namespace: "foo",
1149
-				},
1150
-				Spec: api.RouteSpec{
1151
-					Host: "a*es.wild.test",
1152
-					To:   createRouteSpecTo("serviceName", "Service"),
1153
-				},
1154
-			},
1155
-			errorExpectation: true,
1156
-		},
1157
-	}
1158
-
1159
-	for _, tc := range tests {
1160
-		errs := ValidateRoute(tc.route)
1161
-
1162
-		if tc.errorExpectation {
1163
-			if len(errs) == 0 {
1164
-				t.Errorf("Test case %s expected error(s), got none.", tc.name)
1165
-			}
1166
-		} else if len(errs) > 1 {
1167
-			t.Errorf("Test case %s expected no error(s), got %d: %v", tc.name, len(errs), errs)
1168
-		}
1169
-	}
1170
-}
1171 1028
deleted file mode 100644
... ...
@@ -1,204 +0,0 @@
1
-package controller
2
-
3
-import (
4
-	"fmt"
5
-	"strings"
6
-
7
-	"github.com/golang/glog"
8
-	kapi "k8s.io/kubernetes/pkg/api"
9
-	"k8s.io/kubernetes/pkg/util/sets"
10
-	"k8s.io/kubernetes/pkg/watch"
11
-
12
-	routeapi "github.com/openshift/origin/pkg/route/api"
13
-	"github.com/openshift/origin/pkg/router"
14
-)
15
-
16
-// RouteAdmissionFunc determines whether or not to admit a route.
17
-type RouteAdmissionFunc func(*routeapi.Route) error
18
-
19
-// SubdomainToRouteMap contains all routes associated with a subdomain -
20
-// fully qualified and wildcard routes.
21
-type SubdomainToRouteMap map[string][]*routeapi.Route
22
-
23
-// RemoveRoute removes any existing route(s) for a subdomain.
24
-func (srm SubdomainToRouteMap) RemoveRoute(key string, route *routeapi.Route) bool {
25
-	k := 0
26
-	removed := false
27
-
28
-	m := srm[key]
29
-	for i, v := range m {
30
-		if m[i].Namespace == route.Namespace && m[i].Name == route.Name {
31
-			removed = true
32
-		} else {
33
-			m[k] = v
34
-			k++
35
-		}
36
-	}
37
-
38
-	// set the slice length to the final size.
39
-	m = m[:k]
40
-
41
-	if len(m) > 0 {
42
-		srm[key] = m
43
-	} else {
44
-		delete(srm, key)
45
-	}
46
-
47
-	return removed
48
-}
49
-
50
-func (srm SubdomainToRouteMap) InsertRoute(key string, route *routeapi.Route) {
51
-	// To replace any existing route[s], first we remove all old entries.
52
-	srm.RemoveRoute(key, route)
53
-
54
-	m := srm[key]
55
-	for idx := range m {
56
-		if routeapi.RouteLessThan(route, m[idx]) {
57
-			m = append(m, &routeapi.Route{})
58
-			// From: https://github.com/golang/go/wiki/SliceTricks
59
-			copy(m[idx+1:], m[idx:])
60
-			m[idx] = route
61
-			srm[key] = m
62
-
63
-			// Ensure we return from here as we change the iterator.
64
-			return
65
-		}
66
-	}
67
-
68
-	// Newest route or empty slice, add to the end.
69
-	srm[key] = append(m, route)
70
-}
71
-
72
-// HostAdmitter implements the router.Plugin interface to add admission
73
-// control checks for routes in template based, backend-agnostic routers.
74
-type HostAdmitter struct {
75
-	// plugin is the next plugin in the chain.
76
-	plugin router.Plugin
77
-
78
-	// admitter is a route admission function used to determine whether
79
-	// or not to admit routes.
80
-	admitter RouteAdmissionFunc
81
-
82
-	// recorder is an interface for indicating route rejections.
83
-	recorder RejectionRecorder
84
-
85
-	// restrictOwnership adds admission checks to restrict ownership
86
-	// (of subdomains) to a single owner/namespace.
87
-	restrictOwnership bool
88
-
89
-	// subdomainToRoute contains all routes associated with a subdomain
90
-	// (includes fully qualified and wildcard routes).
91
-	subdomainToRoute SubdomainToRouteMap
92
-}
93
-
94
-// NewHostAdmitter creates a plugin wrapper that checks whether or not to
95
-// admit routes and relay them to the next plugin in the chain.
96
-// Recorder is an interface for indicating why a route was rejected.
97
-func NewHostAdmitter(plugin router.Plugin, fn RouteAdmissionFunc, restrict bool, recorder RejectionRecorder) *HostAdmitter {
98
-	return &HostAdmitter{
99
-		plugin:   plugin,
100
-		admitter: fn,
101
-		recorder: recorder,
102
-
103
-		restrictOwnership: restrict,
104
-		subdomainToRoute:  make(SubdomainToRouteMap),
105
-	}
106
-}
107
-
108
-// HandleEndpoints processes watch events on the Endpoints resource.
109
-func (p *HostAdmitter) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error {
110
-	return p.plugin.HandleEndpoints(eventType, endpoints)
111
-}
112
-
113
-// HandleRoute processes watch events on the Route resource.
114
-func (p *HostAdmitter) HandleRoute(eventType watch.EventType, route *routeapi.Route) error {
115
-	if err := p.admitter(route); err != nil {
116
-		glog.Errorf("Route %s not admitted: %s", routeNameKey(route), err.Error())
117
-		p.recorder.RecordRouteRejection(route, "RouteNotAdmitted", err.Error())
118
-		return err
119
-	}
120
-
121
-	if p.restrictOwnership && len(route.Spec.Host) > 0 {
122
-		switch eventType {
123
-		case watch.Added, watch.Modified:
124
-			if err := p.addRoute(route); err != nil {
125
-				glog.Errorf("Route %s not admitted: %s", routeNameKey(route), err.Error())
126
-				p.recorder.RecordRouteRejection(route, "SubdomainAlreadyClaimed", err.Error())
127
-				return err
128
-			}
129
-
130
-		case watch.Deleted:
131
-			if subdomain := getSubdomain(route.Spec.Host); len(subdomain) > 0 {
132
-				p.subdomainToRoute.RemoveRoute(subdomain, route)
133
-			}
134
-		}
135
-	}
136
-
137
-	return p.plugin.HandleRoute(eventType, route)
138
-}
139
-
140
-// HandleAllowedNamespaces limits the scope of valid routes to only those that match
141
-// the provided namespace list.
142
-func (p *HostAdmitter) HandleNamespaces(namespaces sets.String) error {
143
-	return p.plugin.HandleNamespaces(namespaces)
144
-}
145
-
146
-func (p *HostAdmitter) SetLastSyncProcessed(processed bool) error {
147
-	return p.plugin.SetLastSyncProcessed(processed)
148
-}
149
-
150
-// addRoute admits routes based on subdomain ownership - returns errors if the route is not admitted.
151
-func (p *HostAdmitter) addRoute(route *routeapi.Route) error {
152
-	subdomain := getSubdomain(route.Spec.Host)
153
-	if len(subdomain) == 0 {
154
-		return nil
155
-	}
156
-
157
-	routeList, ok := p.subdomainToRoute[subdomain]
158
-	if !ok {
159
-		p.subdomainToRoute.InsertRoute(subdomain, route)
160
-		return nil
161
-	}
162
-
163
-	oldest := routeList[0]
164
-	if oldest.Namespace == route.Namespace {
165
-		p.subdomainToRoute.InsertRoute(subdomain, route)
166
-		return nil
167
-	}
168
-
169
-	// Route is in another namespace, land grab check here.
170
-	if routeapi.RouteLessThan(oldest, route) {
171
-		glog.V(4).Infof("Route %s cannot take subdomain %s from %s", routeNameKey(route), subdomain, routeNameKey(oldest))
172
-		err := fmt.Errorf("a route in another namespace holds subdomain %s and is older than %s", subdomain, route.Name)
173
-		p.recorder.RecordRouteRejection(route, "SubdomainAlreadyClaimed", err.Error())
174
-		return err
175
-	}
176
-
177
-	// Namespace of this route is now the proud owner of the subdomain.
178
-	glog.V(4).Infof("Route %s is reclaiming subdomain %s from namespace %s", routeNameKey(route), subdomain, oldest.Namespace)
179
-
180
-	// Delete all the routes belonging to the previous "owner" (namespace).
181
-	for idx := range routeList {
182
-		msg := fmt.Sprintf("a route in another namespace %s owns subdomain %s", route.Namespace, subdomain)
183
-		glog.V(4).Infof("Route %s not admitted: %s", routeNameKey(routeList[idx]), msg)
184
-		p.recorder.RecordRouteRejection(routeList[idx], "SubdomainAlreadyClaimed", msg)
185
-		p.plugin.HandleRoute(watch.Deleted, routeList[idx])
186
-	}
187
-
188
-	// And claim the subdomain.
189
-	p.subdomainToRoute[subdomain] = []*routeapi.Route{route}
190
-	return nil
191
-}
192
-
193
-func getSubdomain(host string) string {
194
-	if len(host) < 1 {
195
-		return host
196
-	}
197
-
198
-	parts := strings.SplitAfterN(host, ".", 2)
199
-	if len(parts) < 2 {
200
-		return ""
201
-	}
202
-
203
-	return parts[1]
204
-}
205 1
deleted file mode 100644
... ...
@@ -1,317 +0,0 @@
1
-package controller
2
-
3
-import (
4
-	"fmt"
5
-	"strings"
6
-	"testing"
7
-	"time"
8
-
9
-	kapi "k8s.io/kubernetes/pkg/api"
10
-	"k8s.io/kubernetes/pkg/api/unversioned"
11
-	"k8s.io/kubernetes/pkg/watch"
12
-
13
-	routeapi "github.com/openshift/origin/pkg/route/api"
14
-)
15
-
16
-const (
17
-	BlockedTestDomain = "domain.blocked.test"
18
-)
19
-
20
-type rejectionRecorder struct {
21
-	rejections map[string]string
22
-}
23
-
24
-func (_ rejectionRecorder) rejectionKey(route *routeapi.Route) string {
25
-	return route.Namespace + "-" + route.Name
26
-}
27
-
28
-func (r rejectionRecorder) RecordRouteRejection(route *routeapi.Route, reason, message string) {
29
-	r.rejections[r.rejectionKey(route)] = reason
30
-}
31
-
32
-func wildcardAdmitter(route *routeapi.Route) error {
33
-	if len(route.Spec.Host) < 1 {
34
-		return nil
35
-	}
36
-
37
-	if strings.HasSuffix(route.Spec.Host, "."+BlockedTestDomain) {
38
-		return fmt.Errorf("host is not allowed")
39
-	}
40
-
41
-	return nil
42
-}
43
-
44
-func wildcardRejecter(route *routeapi.Route) error {
45
-	if len(route.Spec.Host) < 1 {
46
-		return nil
47
-	}
48
-
49
-	if strings.HasSuffix(route.Spec.Host, "."+BlockedTestDomain) {
50
-		return fmt.Errorf("host is not allowed")
51
-	}
52
-
53
-	_, wildcard := routeapi.NormalizeWildcardHost(route.Spec.Host)
54
-	if wildcard {
55
-		return fmt.Errorf("wildcards not admitted test")
56
-	}
57
-
58
-	return nil
59
-}
60
-
61
-func TestHostAdmit(t *testing.T) {
62
-	p := &fakePlugin{}
63
-	admitter := NewHostAdmitter(p, wildcardAdmitter, true, LogRejections)
64
-	tests := []struct {
65
-		name   string
66
-		host   string
67
-		errors bool
68
-	}{
69
-		{
70
-			name:   "nohost",
71
-			errors: false,
72
-		},
73
-		{
74
-			name:   "allowed",
75
-			host:   "www.host.admission.test",
76
-			errors: false,
77
-		},
78
-		{
79
-			name:   "blocked",
80
-			host:   "www." + BlockedTestDomain,
81
-			errors: true,
82
-		},
83
-		{
84
-			name:   "wildcard",
85
-			host:   "*.aces.wild.test",
86
-			errors: false,
87
-		},
88
-		{
89
-			name:   "blockedwildcard",
90
-			host:   "*." + BlockedTestDomain,
91
-			errors: true,
92
-		},
93
-	}
94
-
95
-	for _, tc := range tests {
96
-		route := &routeapi.Route{
97
-			ObjectMeta: kapi.ObjectMeta{
98
-				Name:      tc.name,
99
-				Namespace: "allow",
100
-			},
101
-			Spec: routeapi.RouteSpec{Host: tc.host},
102
-		}
103
-
104
-		err := admitter.HandleRoute(watch.Added, route)
105
-		if tc.errors {
106
-			if err == nil {
107
-				t.Fatalf("Test case %s expected errors, got none", tc.name)
108
-			}
109
-		} else {
110
-			if err != nil {
111
-				t.Fatalf("Test case %s expected no errors, got %v", tc.name, err)
112
-			}
113
-		}
114
-	}
115
-}
116
-
117
-func TestWildcardHostDeny(t *testing.T) {
118
-	p := &fakePlugin{}
119
-	admitter := NewHostAdmitter(p, wildcardRejecter, false, LogRejections)
120
-	tests := []struct {
121
-		name   string
122
-		host   string
123
-		errors bool
124
-	}{
125
-		{
126
-			name:   "nohost",
127
-			errors: false,
128
-		},
129
-		{
130
-			name:   "allowed",
131
-			host:   "www.host.admission.test",
132
-			errors: false,
133
-		},
134
-		{
135
-			name:   "blocked",
136
-			host:   "www.wildcard." + BlockedTestDomain,
137
-			errors: true,
138
-		},
139
-		{
140
-			name:   "wildcard",
141
-			host:   "*.aces.wild.test",
142
-			errors: true,
143
-		},
144
-		{
145
-			name:   "blockedwildcard",
146
-			host:   "*.wildcard." + BlockedTestDomain,
147
-			errors: true,
148
-		},
149
-		{
150
-			name:   "anotherblockedwildcard",
151
-			host:   "api.wildcard." + BlockedTestDomain,
152
-			errors: true,
153
-		},
154
-	}
155
-
156
-	for _, tc := range tests {
157
-		route := &routeapi.Route{
158
-			ObjectMeta: kapi.ObjectMeta{
159
-				Name:      tc.name,
160
-				Namespace: "deny",
161
-			},
162
-			Spec: routeapi.RouteSpec{Host: tc.host},
163
-		}
164
-
165
-		err := admitter.HandleRoute(watch.Added, route)
166
-		if tc.errors {
167
-			if err == nil {
168
-				t.Fatalf("Test case %s expected errors, got none", tc.name)
169
-			}
170
-		} else {
171
-			if err != nil {
172
-				t.Fatalf("Test case %s expected no errors, got %v", tc.name, err)
173
-			}
174
-		}
175
-	}
176
-}
177
-
178
-func TestWildcardSubDomainOwnership(t *testing.T) {
179
-	p := &fakePlugin{}
180
-
181
-	recorder := rejectionRecorder{rejections: make(map[string]string)}
182
-	admitter := NewHostAdmitter(p, wildcardAdmitter, true, recorder)
183
-
184
-	oldest := unversioned.Time{Time: time.Now()}
185
-
186
-	ownerRoute := &routeapi.Route{
187
-		ObjectMeta: kapi.ObjectMeta{
188
-			CreationTimestamp: oldest,
189
-			Name:              "first",
190
-			Namespace:         "owner",
191
-		},
192
-		Spec: routeapi.RouteSpec{
193
-			Host: "owner.namespace.test",
194
-		},
195
-	}
196
-
197
-	err := admitter.HandleRoute(watch.Added, ownerRoute)
198
-	if err != nil {
199
-		t.Fatalf("Owner route not admitted: %v", err)
200
-	}
201
-
202
-	tests := []struct {
203
-		createdAt unversioned.Time
204
-		name      string
205
-		namespace string
206
-		host      string
207
-		reason    string
208
-	}{
209
-		{
210
-			name:      "nohost",
211
-			namespace: "something",
212
-		},
213
-		{
214
-			name:      "blockedhost",
215
-			namespace: "blocked",
216
-			host:      "www.wildcard." + BlockedTestDomain,
217
-			reason:    "RouteNotAdmitted",
218
-		},
219
-		{
220
-			createdAt: unversioned.Time{Time: oldest.Add(2 * time.Hour)},
221
-			name:      "diffnamespace",
222
-			namespace: "notowner",
223
-			host:      "www.namespace.test",
224
-			reason:    "SubdomainAlreadyClaimed",
225
-		},
226
-		{
227
-			createdAt: unversioned.Time{Time: oldest.Add(2 * time.Hour)},
228
-			name:      "diffns2",
229
-			namespace: "fortytwo",
230
-			host:      "www.namespace.test",
231
-			reason:    "SubdomainAlreadyClaimed",
232
-		},
233
-		{
234
-			createdAt: unversioned.Time{Time: oldest.Add(3 * time.Hour)},
235
-			name:      "host2diffns2",
236
-			namespace: "fortytwo",
237
-			host:      "api.namespace.test",
238
-			reason:    "SubdomainAlreadyClaimed",
239
-		},
240
-		{
241
-			createdAt: unversioned.Time{Time: oldest.Add(4 * time.Hour)},
242
-			name:      "ownernshost",
243
-			namespace: "owner",
244
-			host:      "api.namespace.test",
245
-		},
246
-	}
247
-
248
-	for _, tc := range tests {
249
-		route := &routeapi.Route{
250
-			ObjectMeta: kapi.ObjectMeta{
251
-				CreationTimestamp: tc.createdAt,
252
-				Name:              tc.name,
253
-				Namespace:         tc.namespace,
254
-			},
255
-			Spec: routeapi.RouteSpec{Host: tc.host},
256
-		}
257
-
258
-		err := admitter.HandleRoute(watch.Added, route)
259
-		if tc.reason != "" {
260
-			if err == nil {
261
-				t.Fatalf("Test case %s expected errors, got none", tc.name)
262
-			}
263
-
264
-			k := recorder.rejectionKey(route)
265
-			if recorder.rejections[k] != tc.reason {
266
-				t.Fatalf("Test case %s expected error %s, got %s", tc.name, tc.reason, recorder.rejections[k])
267
-			}
268
-		} else {
269
-			if err != nil {
270
-				t.Fatalf("Test case %s expected no errors, got %v", tc.name, err)
271
-			}
272
-		}
273
-	}
274
-
275
-	wildcardRoute := &routeapi.Route{
276
-		ObjectMeta: kapi.ObjectMeta{
277
-			CreationTimestamp: unversioned.Time{Time: oldest.Add(time.Hour)},
278
-			Name:              "wildcard-owner",
279
-			Namespace:         "owner",
280
-		},
281
-		Spec: routeapi.RouteSpec{
282
-			Host: "*.namespace.test",
283
-		},
284
-	}
285
-
286
-	err = admitter.HandleRoute(watch.Added, wildcardRoute)
287
-	if err != nil {
288
-		t.Fatalf("Wildcard route not admitted: %v", err)
289
-	}
290
-
291
-	// bounce all the routes from the namespace "owner" and claim
292
-	// ownership of the subdomain for the namespace "bouncer".
293
-	bouncer := &routeapi.Route{
294
-		ObjectMeta: kapi.ObjectMeta{
295
-			CreationTimestamp: unversioned.Time{Time: oldest.Add(-1 * time.Hour)},
296
-			Name:              "hosted",
297
-			Namespace:         "bouncer",
298
-		},
299
-		Spec: routeapi.RouteSpec{
300
-			Host: "api.namespace.test",
301
-		},
302
-	}
303
-
304
-	err = admitter.HandleRoute(watch.Added, bouncer)
305
-	if err != nil {
306
-		t.Fatalf("bouncer route expected no errors, got %v", err)
307
-	}
308
-
309
-	// The bouncer route should kick out the owner and wildcard routes.
310
-	bouncedRoutes := []*routeapi.Route{ownerRoute, wildcardRoute}
311
-	for _, route := range bouncedRoutes {
312
-		k := recorder.rejectionKey(route)
313
-		if recorder.rejections[k] != "SubdomainAlreadyClaimed" {
314
-			t.Fatalf("bounced route %s expected a subdomain already claimed error, got %s", k, recorder.rejections[k])
315
-		}
316
-	}
317
-}
... ...
@@ -107,8 +107,6 @@ func NewTemplatePlugin(cfg TemplatePluginConfig, lookupSvc ServiceLookup) (*Temp
107 107
 		"matchPattern":      matchPattern,      //anchors provided regular expression and evaluates against given string
108 108
 		"isInteger":         isInteger,         //determines if a given variable is an integer
109 109
 		"matchValues":       matchValues,       //compares a given string to a list of allowed strings
110
-
111
-		"genDomainWildcardRegexp": genDomainWildcardRegexp, //generates a regular expression matching wildcard hosts (and paths) for a [sub]domain
112 110
 	}
113 111
 	masterTemplate, err := template.New("config").Funcs(globalFuncs).ParseFiles(cfg.TemplatePath)
114 112
 	if err != nil {
... ...
@@ -203,23 +203,6 @@ func matchPattern(pattern, s string) bool {
203 203
 	return false
204 204
 }
205 205
 
206
-// Generate a regular expression to match wildcard hosts (and paths if any)
207
-// for a [sub]domain.
208
-func genDomainWildcardRegexp(hostname, path string, exactPath bool) string {
209
-	route := &routeapi.Route{Spec: routeapi.RouteSpec{Host: hostname}}
210
-	host, wildcard := routeapi.NormalizeWildcardHost(route.Spec.Host)
211
-	if !wildcard {
212
-		return fmt.Sprintf("%s%s", host, path)
213
-	}
214
-
215
-	expr := regexp.QuoteMeta(fmt.Sprintf(".%s%s", host, path))
216
-	if exactPath {
217
-		return fmt.Sprintf("[^\\.]*%s", expr)
218
-	}
219
-
220
-	return fmt.Sprintf("[^\\.]*%s(|/.*)", expr)
221
-}
222
-
223 206
 func endpointsForAlias(alias ServiceAliasConfig, svc ServiceUnit) []Endpoint {
224 207
 	if len(alias.PreferPort) == 0 {
225 208
 		return svc.EndpointTable
... ...
@@ -531,7 +514,6 @@ func (r *templateRouter) routeKey(route *routeapi.Route) string {
531 531
 func (r *templateRouter) AddRoute(serviceID string, weight int32, route *routeapi.Route, host string) bool {
532 532
 	backendKey := r.routeKey(route)
533 533
 
534
-	_, wildcard := routeapi.NormalizeWildcardHost(route.Spec.Host)
535 534
 	config, ok := r.state[backendKey]
536 535
 
537 536
 	if !ok {
... ...
@@ -540,7 +522,6 @@ func (r *templateRouter) AddRoute(serviceID string, weight int32, route *routeap
540 540
 			Namespace:        route.Namespace,
541 541
 			Host:             host,
542 542
 			Path:             route.Spec.Path,
543
-			IsWildcard:       wildcard,
544 543
 			Annotations:      route.Annotations,
545 544
 			ServiceUnitNames: make(map[string]int32),
546 545
 		}
... ...
@@ -43,9 +43,6 @@ type ServiceAliasConfig struct {
43 43
 	// Hash of the route name - used to obscure cookieId
44 44
 	RoutingKeyName string
45 45
 
46
-	// IsWildcard indicates this service unit needs wildcarding support.
47
-	IsWildcard bool
48
-
49 46
 	// Annotations attached to this route
50 47
 	Annotations map[string]string
51 48