Skip to content

Commit 1e9f630

Browse files
authored
Merge pull request #554 from estroz/dynamic-restmapper
⚠️ DynamicRESTMapper that reloads on REST cache miss
2 parents bc91403 + a695d98 commit 1e9f630

File tree

12 files changed

+774
-83
lines changed

12 files changed

+774
-83
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ require (
1818
go.uber.org/atomic v1.3.2 // indirect
1919
go.uber.org/multierr v1.1.0 // indirect
2020
go.uber.org/zap v1.9.1
21-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
22-
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
21+
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2
22+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
2323
gomodules.xyz/jsonpatch/v2 v2.0.1
2424
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
2525
gopkg.in/fsnotify.v1 v1.4.7

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
213213
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
214214
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
215215
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
216+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
217+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
216218
gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=
217219
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
218220
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
@@ -259,7 +261,6 @@ k8s.io/klog v0.3.3 h1:niceAagH1tzskmaie/icWd7ci1wbG7Bf2c6YGcQv+3c=
259261
k8s.io/klog v0.3.3/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
260262
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI=
261263
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
262-
k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4=
263264
k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
264265
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y=
265266
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=

hack/test-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ setup_envs
2222

2323
header_text "running go test"
2424

25+
# TODO(directxman12): enable the race detector once the LeaderElector race condition is resolved in client-go
2526
go test ${MOD_OPT} ./... -parallel 4
2627

2728
header_text "running coverage"

pkg/cache/cache_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
115115
informerCache, err = createCacheFunc(cfg, cache.Options{})
116116
Expect(err).NotTo(HaveOccurred())
117117
By("running the cache and waiting for it to sync")
118-
go func() {
118+
// pass as an arg so that we don't race between close and re-assign
119+
go func(stopCh chan struct{}) {
119120
defer GinkgoRecover()
120-
Expect(informerCache.Start(stop)).To(Succeed())
121-
}()
121+
Expect(informerCache.Start(stopCh)).To(Succeed())
122+
}(stop)
122123
Expect(informerCache.WaitForCacheSync(stop)).To(BeTrue())
123124
})
124125

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package apiutil_test
18+
19+
import (
20+
"testing"
21+
22+
. "github.com/onsi/ginkgo"
23+
. "github.com/onsi/gomega"
24+
"k8s.io/client-go/rest"
25+
"sigs.k8s.io/controller-runtime/pkg/envtest"
26+
27+
logf "sigs.k8s.io/controller-runtime/pkg/log"
28+
"sigs.k8s.io/controller-runtime/pkg/log/zap"
29+
)
30+
31+
func TestSource(t *testing.T) {
32+
RegisterFailHandler(Fail)
33+
RunSpecsWithDefaultAndCustomReporters(t, "API Utilities Test Suite", []Reporter{envtest.NewlineReporter{}})
34+
}
35+
36+
var cfg *rest.Config
37+
38+
var _ = BeforeSuite(func(done Done) {
39+
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
40+
41+
// for things that technically need a rest.Config for defaulting, but don't actually use them
42+
cfg = &rest.Config{}
43+
44+
close(done)
45+
}, 60)

0 commit comments

Comments
 (0)