Skip to content

Commit b18ad3e

Browse files
authored
Revert kube dependency upgrade (mongodb#1487)
* Revert kube dependency upgrade * Revert removal of deprecated methods * Revert fix test
1 parent f33768e commit b18ad3e

File tree

11 files changed

+588
-200
lines changed

11 files changed

+588
-200
lines changed

cmd/manager/main.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"k8s.io/apimachinery/pkg/runtime"
1212
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1313
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
14-
"sigs.k8s.io/controller-runtime/pkg/cache"
1514
"sigs.k8s.io/controller-runtime/pkg/client/config"
1615
"sigs.k8s.io/controller-runtime/pkg/manager"
1716
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
@@ -83,11 +82,8 @@ func main() {
8382

8483
// Create a new Cmd to provide shared dependencies and start components
8584
mgr, err := manager.New(cfg, manager.Options{
86-
Cache: cache.Options{
87-
DefaultNamespaces: map[string]cache.Config{
88-
watchNamespace: {},
89-
},
90-
}})
85+
Namespace: watchNamespace,
86+
})
9187
if err != nil {
9288
log.Sugar().Fatalf("Unable to create manager: %v", err)
9389
}

controllers/replica_set_controller.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2323
"sigs.k8s.io/controller-runtime/pkg/manager"
2424
"sigs.k8s.io/controller-runtime/pkg/reconcile"
25+
"sigs.k8s.io/controller-runtime/pkg/source"
2526

2627
"github.com/imdario/mergo"
2728
mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1"
@@ -79,8 +80,8 @@ func (r *ReplicaSetReconciler) SetupWithManager(mgr ctrl.Manager) error {
7980
return ctrl.NewControllerManagedBy(mgr).
8081
WithOptions(controller.Options{MaxConcurrentReconciles: 3}).
8182
For(&mdbv1.MongoDBCommunity{}, builder.WithPredicates(predicates.OnlyOnSpecChange())).
82-
Watches(&corev1.Secret{}, r.secretWatcher).
83-
Watches(&corev1.ConfigMap{}, r.configMapWatcher).
83+
Watches(&source.Kind{Type: &corev1.Secret{}}, r.secretWatcher).
84+
Watches(&source.Kind{Type: &corev1.ConfigMap{}}, r.configMapWatcher).
8485
Owns(&appsv1.StatefulSet{}).
8586
Complete(r)
8687
}

controllers/watch/watch.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package watch
22

33
import (
4-
"context"
5-
64
"github.com/mongodb/mongodb-kubernetes-operator/pkg/util/contains"
75
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
86
"k8s.io/apimachinery/pkg/types"
@@ -40,19 +38,19 @@ func (w ResourceWatcher) Watch(watchedName, dependentName types.NamespacedName)
4038
w.watched[watchedName] = append(existing, dependentName)
4139
}
4240

43-
func (w ResourceWatcher) Create(ctx context.Context, event event.CreateEvent, queue workqueue.RateLimitingInterface) {
41+
func (w ResourceWatcher) Create(event event.CreateEvent, queue workqueue.RateLimitingInterface) {
4442
w.handleEvent(event.Object, queue)
4543
}
4644

47-
func (w ResourceWatcher) Update(ctx context.Context, event event.UpdateEvent, queue workqueue.RateLimitingInterface) {
45+
func (w ResourceWatcher) Update(event event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4846
w.handleEvent(event.ObjectOld, queue)
4947
}
5048

51-
func (w ResourceWatcher) Delete(ctx context.Context, event event.DeleteEvent, queue workqueue.RateLimitingInterface) {
49+
func (w ResourceWatcher) Delete(event event.DeleteEvent, queue workqueue.RateLimitingInterface) {
5250
w.handleEvent(event.Object, queue)
5351
}
5452

55-
func (w ResourceWatcher) Generic(ctx context.Context, event event.GenericEvent, queue workqueue.RateLimitingInterface) {
53+
func (w ResourceWatcher) Generic(event event.GenericEvent, queue workqueue.RateLimitingInterface) {
5654
w.handleEvent(event.Object, queue)
5755
}
5856

controllers/watch/watch_test.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package watch
22

33
import (
4-
"context"
54
"testing"
65

76
"k8s.io/apimachinery/pkg/types"
@@ -44,9 +43,9 @@ func TestWatcher(t *testing.T) {
4443

4544
t.Run("Non-watched object", func(t *testing.T) {
4645
watcher := New()
47-
queue := &controllertest.Queue{Interface: workqueue.New()}
46+
queue := controllertest.Queue{Interface: workqueue.New()}
4847

49-
watcher.Create(context.Background(), event.CreateEvent{
48+
watcher.Create(event.CreateEvent{
5049
Object: obj,
5150
}, queue)
5251

@@ -56,11 +55,11 @@ func TestWatcher(t *testing.T) {
5655

5756
t.Run("Multiple objects to reconcile", func(t *testing.T) {
5857
watcher := New()
59-
queue := &controllertest.Queue{Interface: workqueue.New()}
58+
queue := controllertest.Queue{Interface: workqueue.New()}
6059
watcher.Watch(objNsName, mdb1.NamespacedName())
6160
watcher.Watch(objNsName, mdb2.NamespacedName())
6261

63-
watcher.Create(context.Background(), event.CreateEvent{
62+
watcher.Create(event.CreateEvent{
6463
Object: obj,
6564
}, queue)
6665

@@ -70,10 +69,10 @@ func TestWatcher(t *testing.T) {
7069

7170
t.Run("Create event", func(t *testing.T) {
7271
watcher := New()
73-
queue := &controllertest.Queue{Interface: workqueue.New()}
72+
queue := controllertest.Queue{Interface: workqueue.New()}
7473
watcher.Watch(objNsName, mdb1.NamespacedName())
7574

76-
watcher.Create(context.Background(), event.CreateEvent{
75+
watcher.Create(event.CreateEvent{
7776
Object: obj,
7877
}, queue)
7978

@@ -82,10 +81,10 @@ func TestWatcher(t *testing.T) {
8281

8382
t.Run("Update event", func(t *testing.T) {
8483
watcher := New()
85-
queue := &controllertest.Queue{Interface: workqueue.New()}
84+
queue := controllertest.Queue{Interface: workqueue.New()}
8685
watcher.Watch(objNsName, mdb1.NamespacedName())
8786

88-
watcher.Update(context.Background(), event.UpdateEvent{
87+
watcher.Update(event.UpdateEvent{
8988
ObjectOld: obj,
9089
ObjectNew: obj,
9190
}, queue)
@@ -95,10 +94,10 @@ func TestWatcher(t *testing.T) {
9594

9695
t.Run("Delete event", func(t *testing.T) {
9796
watcher := New()
98-
queue := &controllertest.Queue{Interface: workqueue.New()}
97+
queue := controllertest.Queue{Interface: workqueue.New()}
9998
watcher.Watch(objNsName, mdb1.NamespacedName())
10099

101-
watcher.Delete(context.Background(), event.DeleteEvent{
100+
watcher.Delete(event.DeleteEvent{
102101
Object: obj,
103102
}, queue)
104103

@@ -107,10 +106,10 @@ func TestWatcher(t *testing.T) {
107106

108107
t.Run("Generic event", func(t *testing.T) {
109108
watcher := New()
110-
queue := &controllertest.Queue{Interface: workqueue.New()}
109+
queue := controllertest.Queue{Interface: workqueue.New()}
111110
watcher.Watch(objNsName, mdb1.NamespacedName())
112111

113-
watcher.Generic(context.Background(), event.GenericEvent{
112+
watcher.Generic(event.GenericEvent{
114113
Object: obj,
115114
}, queue)
116115

go.mod

+36-39
Original file line numberDiff line numberDiff line change
@@ -14,77 +14,74 @@ require (
1414
go.mongodb.org/mongo-driver v1.13.1
1515
go.uber.org/zap v1.26.0
1616
gopkg.in/natefinch/lumberjack.v2 v2.2.1
17-
k8s.io/api v0.29.0
18-
k8s.io/apimachinery v0.29.0
19-
k8s.io/client-go v0.29.0
20-
sigs.k8s.io/controller-runtime v0.17.0
17+
k8s.io/api v0.26.10
18+
k8s.io/apimachinery v0.26.10
19+
k8s.io/client-go v0.26.10
20+
sigs.k8s.io/controller-runtime v0.14.7
2121
sigs.k8s.io/yaml v1.4.0
2222
)
2323

2424
require (
2525
github.com/beorn7/perks v1.0.1 // indirect
26-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
26+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
2727
github.com/davecgh/go-spew v1.1.1 // indirect
28-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
29-
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
30-
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
31-
github.com/fsnotify/fsnotify v1.7.0 // indirect
32-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
33-
github.com/go-openapi/jsonreference v0.20.2 // indirect
34-
github.com/go-openapi/swag v0.22.3 // indirect
28+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
29+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
30+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
31+
github.com/fsnotify/fsnotify v1.6.0 // indirect
32+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
33+
github.com/go-openapi/jsonreference v0.20.0 // indirect
34+
github.com/go-openapi/swag v0.19.14 // indirect
3535
github.com/gogo/protobuf v1.3.2 // indirect
3636
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
37-
github.com/golang/protobuf v1.5.3 // indirect
37+
github.com/golang/protobuf v1.5.2 // indirect
3838
github.com/golang/snappy v0.0.3 // indirect
39-
github.com/google/gnostic-models v0.6.8 // indirect
40-
github.com/google/go-cmp v0.6.0 // indirect
41-
github.com/google/gofuzz v1.2.0 // indirect
39+
github.com/google/gnostic v0.5.7-v3refs // indirect
40+
github.com/google/go-cmp v0.5.9 // indirect
41+
github.com/google/gofuzz v1.1.0 // indirect
4242
github.com/google/uuid v1.3.0 // indirect
43-
github.com/gorilla/websocket v1.5.0 // indirect
4443
github.com/hashicorp/errwrap v1.0.0 // indirect
4544
github.com/josharian/intern v1.0.0 // indirect
4645
github.com/json-iterator/go v1.1.12 // indirect
4746
github.com/klauspost/compress v1.13.6 // indirect
48-
github.com/mailru/easyjson v0.7.7 // indirect
49-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
47+
github.com/mailru/easyjson v0.7.6 // indirect
48+
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
5049
github.com/moby/spdystream v0.2.0 // indirect
5150
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5251
github.com/modern-go/reflect2 v1.0.2 // indirect
5352
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
5453
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
55-
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
5654
github.com/pkg/errors v0.9.1 // indirect
5755
github.com/pmezard/go-difflib v1.0.0 // indirect
58-
github.com/prometheus/client_golang v1.18.0 // indirect
59-
github.com/prometheus/client_model v0.5.0 // indirect
60-
github.com/prometheus/common v0.45.0 // indirect
61-
github.com/prometheus/procfs v0.12.0 // indirect
56+
github.com/prometheus/client_golang v1.14.0 // indirect
57+
github.com/prometheus/client_model v0.3.0 // indirect
58+
github.com/prometheus/common v0.37.0 // indirect
59+
github.com/prometheus/procfs v0.8.0 // indirect
6260
github.com/spf13/pflag v1.0.5 // indirect
6361
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
6462
github.com/xdg-go/scram v1.1.2 // indirect
6563
github.com/xdg-go/stringprep v1.0.4 // indirect
6664
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
67-
go.uber.org/multierr v1.11.0 // indirect
65+
go.uber.org/multierr v1.10.0 // indirect
6866
golang.org/x/crypto v0.17.0 // indirect
69-
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
70-
golang.org/x/net v0.19.0 // indirect
71-
golang.org/x/oauth2 v0.12.0 // indirect
72-
golang.org/x/sync v0.5.0 // indirect
73-
golang.org/x/sys v0.16.0 // indirect
67+
golang.org/x/net v0.17.0 // indirect
68+
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
69+
golang.org/x/sync v0.1.0 // indirect
70+
golang.org/x/sys v0.15.0 // indirect
7471
golang.org/x/term v0.15.0 // indirect
7572
golang.org/x/text v0.14.0 // indirect
7673
golang.org/x/time v0.3.0 // indirect
77-
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
74+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
7875
google.golang.org/appengine v1.6.7 // indirect
79-
google.golang.org/protobuf v1.32.0 // indirect
76+
google.golang.org/protobuf v1.28.1 // indirect
8077
gopkg.in/inf.v0 v0.9.1 // indirect
8178
gopkg.in/yaml.v2 v2.4.0 // indirect
8279
gopkg.in/yaml.v3 v3.0.1 // indirect
83-
k8s.io/apiextensions-apiserver v0.29.0 // indirect
84-
k8s.io/component-base v0.29.0 // indirect
85-
k8s.io/klog/v2 v2.110.1 // indirect
86-
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
87-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
88-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
89-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
80+
k8s.io/apiextensions-apiserver v0.26.10 // indirect
81+
k8s.io/component-base v0.26.10 // indirect
82+
k8s.io/klog/v2 v2.80.1 // indirect
83+
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
84+
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
85+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
86+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
9087
)

0 commit comments

Comments
 (0)