-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route hostnames are not admitted correctly #11496
Comments
testcase I used: func TestValidRouteAdmissionFuzzing(t *testing.T) {
p := &fakePlugin{}
admitAll := func(route *routeapi.Route) (error, bool) { return nil, true }
recorder := rejectionRecorder{rejections: make(map[string]string)}
admitter := NewHostAdmitter(p, RouteAdmissionFunc(admitAll), true, recorder)
oldest := unversioned.Time{Time: time.Now()}
makeRoute := func(ns, name, host string, creationTimestamp unversioned.Time) *routeapi.Route {
return &routeapi.Route{
ObjectMeta: kapi.ObjectMeta{Name: name, Namespace: ns, CreationTimestamp: creationTimestamp},
Spec: routeapi.RouteSpec{Host: host},
}
}
makeTime := func(d time.Duration) unversioned.Time {
return unversioned.Time{Time: oldest.Add(d)}
}
routes := []*routeapi.Route{
makeRoute("ns1", "r1", "net", makeTime(0*time.Second)),
makeRoute("ns2", "r2", "com", makeTime(1*time.Second)),
makeRoute("ns3", "r3", "domain1.com", makeTime(2*time.Second)),
makeRoute("ns4", "r4", "domain2.com", makeTime(3*time.Second)),
makeRoute("ns5", "r5", "foo.domain1.com", makeTime(4*time.Second)),
makeRoute("ns6", "r6", "bar.domain1.com", makeTime(5*time.Second)),
makeRoute("ns7", "r7", "*.foo.domain1.com", makeTime(6*time.Second)),
makeRoute("ns8", "r8", "*.bar.domain1.com", makeTime(7*time.Second)),
}
rand.Seed(1)
existing := sets.NewInt()
errors := sets.NewString()
for i := 0; i < 1000; i++ {
add := false
switch {
case len(existing) == len(routes):
add = false
case len(existing) == 0:
add = true
default:
add = (rand.Intn(4) > 0)
}
index := 0
if add {
index = rand.Intn(len(routes))
if existing.Has(index) {
// t.Logf("%d: updated route %d", i, index)
if err := admitter.HandleRoute(watch.Modified, routes[index]); err != nil {
errors.Insert(fmt.Sprintf("error updating route %s/%s: %v", routes[index].Namespace, routes[index].Name, err.Error()))
}
} else {
// t.Logf("%d: added route %d", i, index)
if err := admitter.HandleRoute(watch.Added, routes[index]); err != nil {
errors.Insert(fmt.Sprintf("error adding route %s/%s: %v", routes[index].Namespace, routes[index].Name, err.Error()))
}
}
existing.Insert(index)
} else {
index = existing.List()[rand.Intn(len(existing))]
// t.Logf("%d: deleted route %d", i, index)
if err := admitter.HandleRoute(watch.Deleted, routes[index]); err != nil {
errors.Insert(fmt.Sprintf("error deleting route %s/%s: %v", routes[index].Namespace, routes[index].Name, err.Error()))
}
existing.Delete(index)
}
}
if len(errors) > 0 {
t.Errorf("Unexpected errors:\n%s", strings.Join(errors.List(), "\n"))
}
if len(recorder.rejections) > 0 {
t.Errorf("Unexpected rejections: %#v", recorder.rejections)
}
} |
8 tasks
Fixes in PR: #11550 |
#11550 has landed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Route hostnames are not admitted correctly
Version
openshift v1.4.0-alpha.0+2016d68
kubernetes v1.4.0+776c994
etcd 3.1.0-alpha.1
Steps To Reproduce
Create routes with these hostnames in ns1:
Create routes with these hostnames in ns2:
Current Result
Expected Result
com
in ns2 are admittedcom
route in ns2 is rejected with an "AlreadyClaimed" errorThe text was updated successfully, but these errors were encountered: