Skip to content

Commit 50077a4

Browse files
authored
Merge pull request #2043 from FillZpp/bump-k8s-126
⚠ Bump K8s v0.26.0-alpha.3
2 parents 8da9760 + 4dafb9e commit 50077a4

File tree

9 files changed

+148
-257
lines changed

9 files changed

+148
-257
lines changed

go.mod

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,37 @@ go 1.19
44

55
require (
66
github.com/evanphx/json-patch/v5 v5.6.0
7-
github.com/fsnotify/fsnotify v1.5.4
7+
github.com/fsnotify/fsnotify v1.6.0
88
github.com/go-logr/logr v1.2.3
99
github.com/go-logr/zapr v1.2.3
10-
github.com/google/go-cmp v0.5.8
11-
github.com/onsi/ginkgo/v2 v2.1.4
12-
github.com/onsi/gomega v1.19.0
13-
github.com/prometheus/client_golang v1.12.2
10+
github.com/google/go-cmp v0.5.9
11+
github.com/onsi/ginkgo/v2 v2.4.0
12+
github.com/onsi/gomega v1.23.0
13+
github.com/prometheus/client_golang v1.13.0
1414
github.com/prometheus/client_model v0.2.0
15-
go.uber.org/goleak v1.1.12
15+
go.uber.org/goleak v1.2.0
1616
go.uber.org/zap v1.21.0
17-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
17+
golang.org/x/sys v0.1.0
1818
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
1919
gomodules.xyz/jsonpatch/v2 v2.2.0
20-
k8s.io/api v0.25.0
21-
k8s.io/apiextensions-apiserver v0.25.0
22-
k8s.io/apimachinery v0.25.0
23-
k8s.io/client-go v0.25.0
24-
k8s.io/component-base v0.25.0
25-
k8s.io/klog/v2 v2.70.1
26-
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
20+
k8s.io/api v0.26.0-alpha.3
21+
k8s.io/apiextensions-apiserver v0.26.0-alpha.3
22+
k8s.io/apimachinery v0.26.0-alpha.3
23+
k8s.io/client-go v0.26.0-alpha.3
24+
k8s.io/component-base v0.26.0-alpha.3
25+
k8s.io/klog/v2 v2.80.1
26+
k8s.io/utils v0.0.0-20220922133306-665eaaec4324
2727
sigs.k8s.io/yaml v1.3.0
2828
)
2929

3030
require (
31-
cloud.google.com/go v0.97.0 // indirect
32-
github.com/PuerkitoBio/purell v1.1.1 // indirect
33-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
3431
github.com/beorn7/perks v1.0.1 // indirect
3532
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3633
github.com/davecgh/go-spew v1.1.1 // indirect
37-
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
34+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
3835
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
3936
github.com/go-openapi/jsonpointer v0.19.5 // indirect
40-
github.com/go-openapi/jsonreference v0.19.5 // indirect
37+
github.com/go-openapi/jsonreference v0.20.0 // indirect
4138
github.com/go-openapi/swag v0.19.14 // indirect
4239
github.com/gogo/protobuf v1.3.2 // indirect
4340
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -49,26 +46,27 @@ require (
4946
github.com/josharian/intern v1.0.0 // indirect
5047
github.com/json-iterator/go v1.1.12 // indirect
5148
github.com/mailru/easyjson v0.7.6 // indirect
52-
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
49+
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
5350
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5451
github.com/modern-go/reflect2 v1.0.2 // indirect
5552
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5653
github.com/pkg/errors v0.9.1 // indirect
57-
github.com/prometheus/common v0.32.1 // indirect
58-
github.com/prometheus/procfs v0.7.3 // indirect
54+
github.com/prometheus/common v0.37.0 // indirect
55+
github.com/prometheus/procfs v0.8.0 // indirect
5956
github.com/spf13/pflag v1.0.5 // indirect
6057
go.uber.org/atomic v1.7.0 // indirect
6158
go.uber.org/multierr v1.6.0 // indirect
62-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
63-
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
64-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
65-
golang.org/x/text v0.3.7 // indirect
59+
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
60+
golang.org/x/net v0.1.1-0.20221027164007-c63010009c80 // indirect
61+
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
62+
golang.org/x/term v0.1.0 // indirect
63+
golang.org/x/text v0.4.0 // indirect
6664
google.golang.org/appengine v1.6.7 // indirect
67-
google.golang.org/protobuf v1.28.0 // indirect
65+
google.golang.org/protobuf v1.28.1 // indirect
6866
gopkg.in/inf.v0 v0.9.1 // indirect
6967
gopkg.in/yaml.v2 v2.4.0 // indirect
7068
gopkg.in/yaml.v3 v3.0.1 // indirect
71-
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
69+
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
7270
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
7371
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
7472
)

go.sum

Lines changed: 60 additions & 205 deletions
Large diffs are not rendered by default.

pkg/cache/informer_cache.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"reflect"
2323
"strings"
24+
"time"
2425

2526
apimeta "k8s.io/apimachinery/pkg/api/meta"
2627
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -141,7 +142,7 @@ func (ip *informerCache) GetInformerForKind(ctx context.Context, gvk schema.Grou
141142
if err != nil {
142143
return nil, err
143144
}
144-
return i.Informer, err
145+
return WrapInformer(i.Informer), err
145146
}
146147

147148
// GetInformer returns the informer for the obj.
@@ -155,7 +156,7 @@ func (ip *informerCache) GetInformer(ctx context.Context, obj client.Object) (In
155156
if err != nil {
156157
return nil, err
157158
}
158-
return i.Informer, err
159+
return WrapInformer(i.Informer), err
159160
}
160161

161162
// NeedLeaderElection implements the LeaderElectionRunnable interface
@@ -215,3 +216,20 @@ func indexByField(indexer Informer, field string, extractor client.IndexerFunc)
215216

216217
return indexer.AddIndexers(cache.Indexers{internal.FieldIndexName(field): indexFunc})
217218
}
219+
220+
type informerWrapper struct {
221+
cache.SharedIndexInformer
222+
}
223+
224+
func (iw *informerWrapper) AddEventHandler(handler cache.ResourceEventHandler) {
225+
_, _ = iw.SharedIndexInformer.AddEventHandler(handler)
226+
}
227+
228+
func (iw *informerWrapper) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) {
229+
_, _ = iw.SharedIndexInformer.AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
230+
}
231+
232+
// WrapInformer is a temporary wrapper to make Informer compatible with the SharedIndexInformer in client-go v0.26.0
233+
func WrapInformer(i cache.SharedIndexInformer) Informer {
234+
return &informerWrapper{SharedIndexInformer: i}
235+
}

pkg/cache/informertest/fake_cache.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ func (c *FakeInformers) GetInformerForKind(ctx context.Context, gvk schema.Group
4747
if err != nil {
4848
return nil, err
4949
}
50-
return c.informerFor(gvk, obj)
50+
i, err := c.informerFor(gvk, obj)
51+
if err != nil {
52+
return nil, err
53+
}
54+
return cache.WrapInformer(i), nil
5155
}
5256

5357
// FakeInformerForKind implements Informers.
@@ -76,7 +80,11 @@ func (c *FakeInformers) GetInformer(ctx context.Context, obj client.Object) (cac
7680
return nil, err
7781
}
7882
gvk := gvks[0]
79-
return c.informerFor(gvk, obj)
83+
i, err := c.informerFor(gvk, obj)
84+
if err != nil {
85+
return nil, err
86+
}
87+
return cache.WrapInformer(i), nil
8088
}
8189

8290
// WaitForCacheSync implements Informers.

pkg/controller/controllertest/util.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ func (f *FakeInformer) HasSynced() bool {
5656
return f.Synced
5757
}
5858

59-
// AddEventHandler implements the Informer interface. Adds an EventHandler to the fake Informers.
60-
func (f *FakeInformer) AddEventHandler(handler cache.ResourceEventHandler) {
59+
// AddEventHandler implements the Informer interface. Adds an EventHandler to the fake Informers. TODO(community): Implement Registration.
60+
func (f *FakeInformer) AddEventHandler(handler cache.ResourceEventHandler) (cache.ResourceEventHandlerRegistration, error) {
6161
f.handlers = append(f.handlers, handler)
62+
return nil, nil
6263
}
6364

6465
// Run implements the Informer interface. Increments f.RunCount.
@@ -88,8 +89,13 @@ func (f *FakeInformer) Delete(obj metav1.Object) {
8889
}
8990

9091
// AddEventHandlerWithResyncPeriod does nothing. TODO(community): Implement this.
91-
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) {
92+
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) (cache.ResourceEventHandlerRegistration, error) {
93+
return nil, nil
94+
}
9295

96+
// RemoveEventHandler does nothing. TODO(community): Implement this.
97+
func (f *FakeInformer) RemoveEventHandler(handle cache.ResourceEventHandlerRegistration) error {
98+
return nil
9399
}
94100

95101
// GetStore does nothing. TODO(community): Implement this.
@@ -116,3 +122,8 @@ func (f *FakeInformer) SetWatchErrorHandler(cache.WatchErrorHandler) error {
116122
func (f *FakeInformer) SetTransform(t cache.TransformFunc) error {
117123
return nil
118124
}
125+
126+
// IsStopped does nothing. TODO(community): Implement this.
127+
func (f *FakeInformer) IsStopped() bool {
128+
return false
129+
}

pkg/envtest/crd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func defaultCRDOptions(o *CRDInstallOptions) {
142142
// WaitForCRDs waits for the CRDs to appear in discovery.
143143
func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefinition, options CRDInstallOptions) error {
144144
// Add each CRD to a map of GroupVersion to Resource
145-
waitingFor := map[schema.GroupVersion]*sets.String{}
145+
waitingFor := map[schema.GroupVersion]*sets.Set[string]{}
146146
for _, crd := range crds {
147147
gvs := []schema.GroupVersion{}
148148
for _, version := range crd.Spec.Versions {
@@ -155,7 +155,7 @@ func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefi
155155
log.V(1).Info("adding API in waitlist", "GV", gv)
156156
if _, found := waitingFor[gv]; !found {
157157
// Initialize the set
158-
waitingFor[gv] = &sets.String{}
158+
waitingFor[gv] = &sets.Set[string]{}
159159
}
160160
// Add the Resource
161161
waitingFor[gv].Insert(crd.Spec.Names.Plural)
@@ -173,7 +173,7 @@ type poller struct {
173173
config *rest.Config
174174

175175
// waitingFor is the map of resources keyed by group version that have not yet been found in discovery
176-
waitingFor map[schema.GroupVersion]*sets.String
176+
waitingFor map[schema.GroupVersion]*sets.Set[string]
177177
}
178178

179179
// poll checks if all the resources have been found in discovery, and returns false if not.

pkg/envtest/webhook.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func WaitForWebhooks(config *rest.Config,
173173
mutatingWebhooks []*admissionv1.MutatingWebhookConfiguration,
174174
validatingWebhooks []*admissionv1.ValidatingWebhookConfiguration,
175175
options WebhookInstallOptions) error {
176-
waitingFor := map[schema.GroupVersionKind]*sets.String{}
176+
waitingFor := map[schema.GroupVersionKind]*sets.Set[string]{}
177177

178178
for _, hook := range mutatingWebhooks {
179179
h := hook
@@ -183,7 +183,7 @@ func WaitForWebhooks(config *rest.Config,
183183
}
184184

185185
if _, ok := waitingFor[gvk]; !ok {
186-
waitingFor[gvk] = &sets.String{}
186+
waitingFor[gvk] = &sets.Set[string]{}
187187
}
188188
waitingFor[gvk].Insert(h.GetName())
189189
}
@@ -196,7 +196,7 @@ func WaitForWebhooks(config *rest.Config,
196196
}
197197

198198
if _, ok := waitingFor[gvk]; !ok {
199-
waitingFor[gvk] = &sets.String{}
199+
waitingFor[gvk] = &sets.Set[string]{}
200200
}
201201
waitingFor[gvk].Insert(hook.GetName())
202202
}
@@ -212,7 +212,7 @@ type webhookPoller struct {
212212
config *rest.Config
213213

214214
// waitingFor is the map of resources keyed by group version that have not yet been found in discovery
215-
waitingFor map[schema.GroupVersionKind]*sets.String
215+
waitingFor map[schema.GroupVersionKind]*sets.Set[string]
216216
}
217217

218218
// poll checks if all the resources have been found in discovery, and returns false if not.
@@ -229,7 +229,7 @@ func (p *webhookPoller) poll() (done bool, err error) {
229229
delete(p.waitingFor, gvk)
230230
continue
231231
}
232-
for _, name := range names.List() {
232+
for _, name := range names.UnsortedList() {
233233
var obj = &unstructured.Unstructured{}
234234
obj.SetGroupVersionKind(gvk)
235235
err := c.Get(context.Background(), client.ObjectKey{

pkg/healthz/healthz.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (h *Handler) serveAggregated(resp http.ResponseWriter, req *http.Request) {
7070
parts = append(parts, checkStatus{name: "ping", healthy: true})
7171
}
7272

73-
for _, c := range excluded.List() {
73+
for _, c := range excluded.UnsortedList() {
7474
log.V(1).Info("cannot exclude health check, no matches for it", "checker", c)
7575
}
7676

@@ -88,7 +88,7 @@ func (h *Handler) serveAggregated(resp http.ResponseWriter, req *http.Request) {
8888
// any checks that the user requested to have excluded, but weren't actually
8989
// known checks. writeStatusAsText is always verbose on failure, and can be
9090
// forced to be verbose on success using the given argument.
91-
func writeStatusesAsText(resp http.ResponseWriter, parts []checkStatus, unknownExcludes sets.String, failed, forceVerbose bool) {
91+
func writeStatusesAsText(resp http.ResponseWriter, parts []checkStatus, unknownExcludes sets.Set[string], failed, forceVerbose bool) {
9292
resp.Header().Set("Content-Type", "text/plain; charset=utf-8")
9393
resp.Header().Set("X-Content-Type-Options", "nosniff")
9494

@@ -121,7 +121,7 @@ func writeStatusesAsText(resp http.ResponseWriter, parts []checkStatus, unknownE
121121
}
122122

123123
if unknownExcludes.Len() > 0 {
124-
fmt.Fprintf(resp, "warn: some health checks cannot be excluded: no matches for %s\n", formatQuoted(unknownExcludes.List()...))
124+
fmt.Fprintf(resp, "warn: some health checks cannot be excluded: no matches for %s\n", formatQuoted(unknownExcludes.UnsortedList()...))
125125
}
126126

127127
if failed {
@@ -187,12 +187,12 @@ type Checker func(req *http.Request) error
187187
var Ping Checker = func(_ *http.Request) error { return nil }
188188

189189
// getExcludedChecks extracts the health check names to be excluded from the query param.
190-
func getExcludedChecks(r *http.Request) sets.String {
190+
func getExcludedChecks(r *http.Request) sets.Set[string] {
191191
checks, found := r.URL.Query()["exclude"]
192192
if found {
193-
return sets.NewString(checks...)
193+
return sets.New[string](checks...)
194194
}
195-
return sets.NewString()
195+
return sets.New[string]()
196196
}
197197

198198
// formatQuoted returns a formatted string of the health check names,

pkg/source/source_integration_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"time"
2222

23+
"sigs.k8s.io/controller-runtime/pkg/cache"
2324
"sigs.k8s.io/controller-runtime/pkg/client"
2425
"sigs.k8s.io/controller-runtime/pkg/event"
2526
"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -244,7 +245,7 @@ var _ = Describe("Source", func() {
244245
c := make(chan struct{})
245246

246247
q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test")
247-
instance := &source.Informer{Informer: depInformer}
248+
instance := &source.Informer{Informer: cache.WrapInformer(depInformer)}
248249
err := instance.Start(ctx, handler.Funcs{
249250
CreateFunc: func(evt event.CreateEvent, q2 workqueue.RateLimitingInterface) {
250251
defer GinkgoRecover()
@@ -285,7 +286,7 @@ var _ = Describe("Source", func() {
285286
rs2.SetLabels(map[string]string{"biz": "baz"})
286287

287288
q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test")
288-
instance := &source.Informer{Informer: depInformer}
289+
instance := &source.Informer{Informer: cache.WrapInformer(depInformer)}
289290
err = instance.Start(ctx, handler.Funcs{
290291
CreateFunc: func(evt event.CreateEvent, q2 workqueue.RateLimitingInterface) {
291292
},
@@ -322,7 +323,7 @@ var _ = Describe("Source", func() {
322323
c := make(chan struct{})
323324

324325
q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test")
325-
instance := &source.Informer{Informer: depInformer}
326+
instance := &source.Informer{Informer: cache.WrapInformer(depInformer)}
326327
err := instance.Start(ctx, handler.Funcs{
327328
CreateFunc: func(event.CreateEvent, workqueue.RateLimitingInterface) {
328329
},

0 commit comments

Comments
 (0)