Skip to content

Commit

Permalink
Merge pull request #313 from benluddy/condense-route-allocator-abstra…
Browse files Browse the repository at this point in the history
…ction

Condense the route host allocator abstraction.
  • Loading branch information
openshift-merge-robot committed Sep 30, 2022
2 parents 5d29c08 + 344bdd6 commit 3c720ab
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 200 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/openshift-apiserver/openshiftapiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/openshift/openshift-apiserver/pkg/cmd/openshift-apiserver/openshiftadmission"
"github.com/openshift/openshift-apiserver/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing"
"github.com/openshift/openshift-apiserver/pkg/image/apiserver/registryhostname"
"github.com/openshift/openshift-apiserver/pkg/route/apiserver/simplerouteallocation"
"github.com/openshift/openshift-apiserver/pkg/version"
)

Expand Down Expand Up @@ -215,7 +216,7 @@ func NewOpenshiftAPIConfig(config *openshiftcontrolplanev1.OpenShiftAPIServerCon
informers.GetKubernetesInformers().Rbac().V1(),
)

routeAllocator, err := configprocessing.RouteAllocator(config.RoutingConfig.Subdomain)
routeAllocator, err := simplerouteallocation.NewSimpleAllocationPlugin(config.RoutingConfig.Subdomain)
if err != nil {
return nil, err
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
projectcache "github.com/openshift/openshift-apiserver/pkg/project/cache"
quotaapiserver "github.com/openshift/openshift-apiserver/pkg/quota/apiserver"
routeapiserver "github.com/openshift/openshift-apiserver/pkg/route/apiserver"
"github.com/openshift/openshift-apiserver/pkg/route/apiserver/routeallocationcontroller"
"github.com/openshift/openshift-apiserver/pkg/route/apiserver/simplerouteallocation"
securityapiserver "github.com/openshift/openshift-apiserver/pkg/security/apiserver"
templateapiserver "github.com/openshift/openshift-apiserver/pkg/template/apiserver"
"github.com/openshift/openshift-apiserver/pkg/version"
Expand Down Expand Up @@ -78,7 +78,7 @@ type OpenshiftAPIExtraConfig struct {
MaxImagesBulkImportedPerRepository int
AdditionalTrustedCA []byte

RouteAllocator *routeallocationcontroller.RouteAllocationController
RouteAllocator *simplerouteallocation.SimpleAllocationPlugin

ProjectAuthorizationCache *projectauth.AuthorizationCache
ProjectCache *projectcache.ProjectCache
Expand Down
4 changes: 2 additions & 2 deletions pkg/route/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (

routeapiv1 "github.com/openshift/api/route/v1"
routeetcd "github.com/openshift/openshift-apiserver/pkg/route/apiserver/registry/route/etcd"
"github.com/openshift/openshift-apiserver/pkg/route/apiserver/routeallocationcontroller"
"github.com/openshift/openshift-apiserver/pkg/route/apiserver/simplerouteallocation"
)

type ExtraConfig struct {
KubeAPIServerClientConfig *restclient.Config
RouteAllocator *routeallocationcontroller.RouteAllocationController
RouteAllocator *simplerouteallocation.SimpleAllocationPlugin

// TODO these should all become local eventually
Scheme *runtime.Scheme
Expand Down
2 changes: 0 additions & 2 deletions pkg/route/apiserver/routeallocationcontroller/doc.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/route/apiserver/routeallocationcontroller/factory.go

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/route/apiserver/routeinterfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import (
api "github.com/openshift/openshift-apiserver/pkg/route/apis/route"
)

// AllocationPlugin is the interface the route controller dispatches
// requests for RouterShard allocation and name generation.
type AllocationPlugin interface {
Allocate(*api.Route) (*api.RouterShard, error)
GenerateHostname(*api.Route, *api.RouterShard) string
}

// RouteAllocator is the interface for the route allocation controller
// which handles requests for RouterShard allocation and name generation.
type RouteAllocator interface {
Expand Down
2 changes: 0 additions & 2 deletions pkg/route/apiserver/simplerouteallocation/doc.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/route/apiserver/simplerouteallocation/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewSimpleAllocationPlugin(suffix string) (*SimpleAllocationPlugin, error) {
// Allocate a router shard for the given route. This plugin always returns
// the "global" router shard.
// TODO: replace with per router allocation
func (p *SimpleAllocationPlugin) Allocate(route *routeapi.Route) (*routeapi.RouterShard, error) {
func (p *SimpleAllocationPlugin) AllocateRouterShard(route *routeapi.Route) (*routeapi.RouterShard, error) {
klog.V(4).Infof("Allocating global shard *.%s to Route: %s", p.DNSSuffix, route.Name)

return &routeapi.RouterShard{ShardName: "global", DNSSuffix: p.DNSSuffix}, nil
Expand Down
14 changes: 7 additions & 7 deletions pkg/route/apiserver/simplerouteallocation/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation"

routeapi "github.com/openshift/openshift-apiserver/pkg/route/apis/route"
rac "github.com/openshift/openshift-apiserver/pkg/route/apiserver/routeallocationcontroller"
)

func TestNewSimpleAllocationPlugin(t *testing.T) {
Expand Down Expand Up @@ -142,7 +141,7 @@ func TestSimpleAllocationPlugin(t *testing.T) {
}

for _, tc := range tests {
shard, _ := plugin.Allocate(tc.route)
shard, _ := plugin.AllocateRouterShard(tc.route)
name := plugin.GenerateHostname(tc.route, shard)
switch {
case len(name) == 0 && !tc.empty, len(name) != 0 && tc.empty:
Expand Down Expand Up @@ -228,16 +227,17 @@ func TestSimpleAllocationPluginViaController(t *testing.T) {
},
}

plugin, _ := NewSimpleAllocationPlugin("www.example.org")
fac := &rac.RouteAllocationControllerFactory{}
sac := fac.Create(plugin)
plugin, err := NewSimpleAllocationPlugin("www.example.org")
if err != nil {
t.Fatalf("unexpected error")
}

for _, tc := range tests {
shard, err := sac.AllocateRouterShard(tc.route)
shard, err := plugin.AllocateRouterShard(tc.route)
if err != nil {
t.Errorf("Test case %s got an error %s", tc.name, err)
}
name := sac.GenerateHostname(tc.route, shard)
name := plugin.GenerateHostname(tc.route, shard)
switch {
case len(name) == 0 && !tc.empty, len(name) != 0 && tc.empty:
t.Errorf("Test case %s got %d length name.", tc.name, len(name))
Expand Down

0 comments on commit 3c720ab

Please sign in to comment.