Skip to content
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

⚠ Bump K8s v0.26.0-alpha.3 #2043

Merged
merged 1 commit into from Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 26 additions & 28 deletions go.mod
Expand Up @@ -4,40 +4,37 @@ go 1.19

require (
github.com/evanphx/json-patch/v5 v5.6.0
github.com/fsnotify/fsnotify v1.5.4
github.com/fsnotify/fsnotify v1.6.0
github.com/go-logr/logr v1.2.3
github.com/go-logr/zapr v1.2.3
github.com/google/go-cmp v0.5.8
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/prometheus/client_golang v1.12.2
github.com/google/go-cmp v0.5.9
github.com/onsi/ginkgo/v2 v2.4.0
github.com/onsi/gomega v1.23.0
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0
go.uber.org/goleak v1.1.12
go.uber.org/goleak v1.2.0
go.uber.org/zap v1.21.0
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
golang.org/x/sys v0.1.0
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
gomodules.xyz/jsonpatch/v2 v2.2.0
k8s.io/api v0.25.0
k8s.io/apiextensions-apiserver v0.25.0
k8s.io/apimachinery v0.25.0
k8s.io/client-go v0.25.0
k8s.io/component-base v0.25.0
k8s.io/klog/v2 v2.70.1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
k8s.io/api v0.26.0-alpha.3
k8s.io/apiextensions-apiserver v0.26.0-alpha.3
k8s.io/apimachinery v0.26.0-alpha.3
k8s.io/client-go v0.26.0-alpha.3
k8s.io/component-base v0.26.0-alpha.3
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20220922133306-665eaaec4324
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go v0.97.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -49,26 +46,27 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/net v0.1.1-0.20221027164007-c63010009c80 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
265 changes: 60 additions & 205 deletions go.sum

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions pkg/cache/informer_cache.go
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"reflect"
"strings"
"time"

apimeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -141,7 +142,7 @@ func (ip *informerCache) GetInformerForKind(ctx context.Context, gvk schema.Grou
if err != nil {
return nil, err
}
return i.Informer, err
return WrapInformer(i.Informer), err
}

// GetInformer returns the informer for the obj.
Expand All @@ -155,7 +156,7 @@ func (ip *informerCache) GetInformer(ctx context.Context, obj client.Object) (In
if err != nil {
return nil, err
}
return i.Informer, err
return WrapInformer(i.Informer), err
}

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

return indexer.AddIndexers(cache.Indexers{internal.FieldIndexName(field): indexFunc})
}

type informerWrapper struct {
cache.SharedIndexInformer
}

func (iw *informerWrapper) AddEventHandler(handler cache.ResourceEventHandler) {
_, _ = iw.SharedIndexInformer.AddEventHandler(handler)
}

func (iw *informerWrapper) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) {
_, _ = iw.SharedIndexInformer.AddEventHandlerWithResyncPeriod(handler, resyncPeriod)
}

// WrapInformer is a temporary wrapper to make Informer compatible with the SharedIndexInformer in client-go v0.26.0
func WrapInformer(i cache.SharedIndexInformer) Informer {
return &informerWrapper{SharedIndexInformer: i}
}
12 changes: 10 additions & 2 deletions pkg/cache/informertest/fake_cache.go
Expand Up @@ -47,7 +47,11 @@ func (c *FakeInformers) GetInformerForKind(ctx context.Context, gvk schema.Group
if err != nil {
return nil, err
}
return c.informerFor(gvk, obj)
i, err := c.informerFor(gvk, obj)
if err != nil {
return nil, err
}
return cache.WrapInformer(i), nil
}

// FakeInformerForKind implements Informers.
Expand Down Expand Up @@ -76,7 +80,11 @@ func (c *FakeInformers) GetInformer(ctx context.Context, obj client.Object) (cac
return nil, err
}
gvk := gvks[0]
return c.informerFor(gvk, obj)
i, err := c.informerFor(gvk, obj)
if err != nil {
return nil, err
}
return cache.WrapInformer(i), nil
}

// WaitForCacheSync implements Informers.
Expand Down
17 changes: 14 additions & 3 deletions pkg/controller/controllertest/util.go
Expand Up @@ -56,9 +56,10 @@ func (f *FakeInformer) HasSynced() bool {
return f.Synced
}

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

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

// AddEventHandlerWithResyncPeriod does nothing. TODO(community): Implement this.
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) {
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, resyncPeriod time.Duration) (cache.ResourceEventHandlerRegistration, error) {
return nil, nil
}

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

// GetStore does nothing. TODO(community): Implement this.
Expand All @@ -116,3 +122,8 @@ func (f *FakeInformer) SetWatchErrorHandler(cache.WatchErrorHandler) error {
func (f *FakeInformer) SetTransform(t cache.TransformFunc) error {
return nil
}

// IsStopped does nothing. TODO(community): Implement this.
func (f *FakeInformer) IsStopped() bool {
return false
}
6 changes: 3 additions & 3 deletions pkg/envtest/crd.go
Expand Up @@ -142,7 +142,7 @@ func defaultCRDOptions(o *CRDInstallOptions) {
// WaitForCRDs waits for the CRDs to appear in discovery.
func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefinition, options CRDInstallOptions) error {
// Add each CRD to a map of GroupVersion to Resource
waitingFor := map[schema.GroupVersion]*sets.String{}
waitingFor := map[schema.GroupVersion]*sets.Set[string]{}
for _, crd := range crds {
gvs := []schema.GroupVersion{}
for _, version := range crd.Spec.Versions {
Expand All @@ -155,7 +155,7 @@ func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefi
log.V(1).Info("adding API in waitlist", "GV", gv)
if _, found := waitingFor[gv]; !found {
// Initialize the set
waitingFor[gv] = &sets.String{}
waitingFor[gv] = &sets.Set[string]{}
}
// Add the Resource
waitingFor[gv].Insert(crd.Spec.Names.Plural)
Expand All @@ -173,7 +173,7 @@ type poller struct {
config *rest.Config

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

// poll checks if all the resources have been found in discovery, and returns false if not.
Expand Down
10 changes: 5 additions & 5 deletions pkg/envtest/webhook.go
Expand Up @@ -173,7 +173,7 @@ func WaitForWebhooks(config *rest.Config,
mutatingWebhooks []*admissionv1.MutatingWebhookConfiguration,
validatingWebhooks []*admissionv1.ValidatingWebhookConfiguration,
options WebhookInstallOptions) error {
waitingFor := map[schema.GroupVersionKind]*sets.String{}
waitingFor := map[schema.GroupVersionKind]*sets.Set[string]{}

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

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

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

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

// poll checks if all the resources have been found in discovery, and returns false if not.
Expand All @@ -229,7 +229,7 @@ func (p *webhookPoller) poll() (done bool, err error) {
delete(p.waitingFor, gvk)
continue
}
for _, name := range names.List() {
for _, name := range names.UnsortedList() {
var obj = &unstructured.Unstructured{}
obj.SetGroupVersionKind(gvk)
err := c.Get(context.Background(), client.ObjectKey{
Expand Down
12 changes: 6 additions & 6 deletions pkg/healthz/healthz.go
Expand Up @@ -70,7 +70,7 @@ func (h *Handler) serveAggregated(resp http.ResponseWriter, req *http.Request) {
parts = append(parts, checkStatus{name: "ping", healthy: true})
}

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

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

Expand Down Expand Up @@ -121,7 +121,7 @@ func writeStatusesAsText(resp http.ResponseWriter, parts []checkStatus, unknownE
}

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

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

// getExcludedChecks extracts the health check names to be excluded from the query param.
func getExcludedChecks(r *http.Request) sets.String {
func getExcludedChecks(r *http.Request) sets.Set[string] {
checks, found := r.URL.Query()["exclude"]
if found {
return sets.NewString(checks...)
return sets.New[string](checks...)
}
return sets.NewString()
return sets.New[string]()
}

// formatQuoted returns a formatted string of the health check names,
Expand Down
7 changes: 4 additions & 3 deletions pkg/source/source_integration_test.go
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"time"

"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -244,7 +245,7 @@ var _ = Describe("Source", func() {
c := make(chan struct{})

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

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

q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test")
instance := &source.Informer{Informer: depInformer}
instance := &source.Informer{Informer: cache.WrapInformer(depInformer)}
err := instance.Start(ctx, handler.Funcs{
CreateFunc: func(event.CreateEvent, workqueue.RateLimitingInterface) {
},
Expand Down