Skip to content

Commit 0d8bcfe

Browse files
MHBauerDoug Davis
authored and
Doug Davis
committed
thread through stopCh to DestroyFunc (openshift#1671)
partial mitigation for openshift#1649 still many outstanding goroutines by test end
1 parent 1c45aef commit 0d8bcfe

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Diff for: cmd/apiserver/app/server/run_server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func runEtcdServer(opts *ServiceCatalogServerOptions, stopCh <-chan struct{}) er
101101

102102
// make the server
103103
glog.V(4).Infoln("Completing API server configuration")
104-
server, err := completed.NewServer()
104+
server, err := completed.NewServer(stopCh)
105105
if err != nil {
106106
return fmt.Errorf("error completing API server configuration: %v", err)
107107
}

Diff for: pkg/apiserver/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ type Config interface {
2525
// CompletedConfig is the result of a Config being Complete()-ed. Calling code should call Start()
2626
// to start a server from its completed config
2727
type CompletedConfig interface {
28-
NewServer() (*ServiceCatalogAPIServer, error)
28+
NewServer(stopCh <-chan struct{}) (*ServiceCatalogAPIServer, error)
2929
}

Diff for: pkg/apiserver/etcd_config.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/golang/glog"
2121
"github.com/kubernetes-incubator/service-catalog/pkg/registry/servicecatalog/server"
2222
"k8s.io/apiserver/pkg/registry/generic"
23+
"k8s.io/apiserver/pkg/registry/generic/registry"
2324
genericapiserver "k8s.io/apiserver/pkg/server"
2425
"k8s.io/apiserver/pkg/server/storage"
2526
)
@@ -79,7 +80,7 @@ type completedEtcdConfig struct {
7980

8081
// NewServer creates a new server that can be run. Returns a non-nil error if the server couldn't
8182
// be created
82-
func (c completedEtcdConfig) NewServer() (*ServiceCatalogAPIServer, error) {
83+
func (c completedEtcdConfig) NewServer(stopCh <-chan struct{}) (*ServiceCatalogAPIServer, error) {
8384
s, err := createSkeletonServer(c.genericConfig)
8485
if err != nil {
8586
return nil, err
@@ -110,6 +111,19 @@ func (c completedEtcdConfig) NewServer() (*ServiceCatalogAPIServer, error) {
110111
glog.V(4).Infof("Installing API group %v", provider.GroupName())
111112
if err := s.GenericAPIServer.InstallAPIGroup(groupInfo); err != nil {
112113
glog.Fatalf("Error installing API group %v: %v", provider.GroupName(), err)
114+
} else {
115+
// we've sucessfully installed, so hook the stopCh to the destroy func of all the sucessfully installed apigroups
116+
for _, mappings := range groupInfo.VersionedResourcesStorageMap { // gv to resource mappings
117+
for _, storage := range mappings { // resource name (brokers, brokers/status) to backing storage
118+
go func() {
119+
s, ok := storage.(*registry.Store)
120+
if ok {
121+
<-stopCh
122+
s.DestroyFunc()
123+
}
124+
}()
125+
}
126+
}
113127
}
114128
}
115129

Diff for: test/integration/controller_instance_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func TestCreateServiceInstanceNonExistentClusterServiceClassOrPlan(t *testing.T)
101101
for _, tc := range cases {
102102
tc := tc
103103
t.Run(tc.name, func(t *testing.T) {
104-
t.Parallel()
105104
ct := &controllerTest{
106105
t: t,
107106
broker: getTestBroker(),

0 commit comments

Comments
 (0)