Skip to content

Commit 3e2c6b5

Browse files
authored
Revert "chore: upgrade kubernetes dependencies (#266)" (#267)
This reverts commit 3a3986c.
1 parent 3a3986c commit 3e2c6b5

File tree

12 files changed

+512
-493
lines changed

12 files changed

+512
-493
lines changed

channel/client.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ import (
3030
"k8s.io/client-go/kubernetes/scheme"
3131
"k8s.io/client-go/rest"
3232
"k8s.io/client-go/tools/remotecommand"
33+
"sigs.k8s.io/controller-runtime/pkg/cache"
3334
"sigs.k8s.io/controller-runtime/pkg/client"
35+
"sigs.k8s.io/controller-runtime/pkg/manager"
3436
)
3537

3638
// Client contains the kubernetes client, operator client and kubeconfig
@@ -41,17 +43,25 @@ type Client struct {
4143
}
4244

4345
// NewClientFunc returns the controller client
44-
func NewClientFunc() client.NewClientFunc {
45-
return func(config *rest.Config, options client.Options) (client.Client, error) {
46+
func NewClientFunc() manager.NewClientFunc {
47+
return func(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error) {
48+
// Create the Client for Write operations.
4649
c, err := client.New(config, options)
4750
if err != nil {
4851
return nil, err
4952
}
50-
return &Client{
51-
Interface: kubernetes.NewForConfigOrDie(config),
52-
Client: c,
53-
Config: config,
54-
}, nil
53+
cli := &Client{}
54+
cli.Interface = kubernetes.NewForConfigOrDie(config)
55+
cli.Client = &client.DelegatingClient{
56+
Reader: &client.DelegatingReader{
57+
CacheReader: cache,
58+
ClientReader: c,
59+
},
60+
Writer: c,
61+
StatusClient: c,
62+
}
63+
cli.Config = config
64+
return cli, nil
5565
}
5666
}
5767

cmd/hookfs/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/chaosblade-io/chaosblade-spec-go/util"
2929
"github.com/ethercflow/hookfs/hookfs"
3030
"github.com/sirupsen/logrus"
31-
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
31+
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
3232

3333
chaosbladehook "github.com/chaosblade-io/chaosblade-operator/pkg/hookfs"
3434
)
@@ -52,19 +52,19 @@ func main() {
5252
"original": original,
5353
"mountpoint": mountpoint,
5454
})
55-
stopCtx := signals.SetupSignalHandler()
55+
stopCh := signals.SetupSignalHandler()
5656
chaosbladeHookServer := chaosbladehook.NewChaosbladeHookServer(address)
5757
logFields.Infoln("Start chaosblade hook server.")
58-
go chaosbladeHookServer.Start(stopCtx)
58+
go chaosbladeHookServer.Start(stopCh)
5959

6060
logFields.Infoln("Start fuse server.")
61-
if err := startFuseServer(stopCtx); err != nil {
61+
if err := startFuseServer(stopCh); err != nil {
6262
logFields.WithError(err).Fatalln("Start fuse server failed")
6363
}
6464
}
6565

6666
// startFuseServer starts hookfs server
67-
func startFuseServer(stop context.Context) error {
67+
func startFuseServer(stop <-chan struct{}) error {
6868
if !util.IsExist(original) {
6969
if err := os.MkdirAll(original, os.FileMode(755)); err != nil {
7070
return fmt.Errorf("create original directory error, %v", err)
@@ -85,7 +85,7 @@ func startFuseServer(stop context.Context) error {
8585
}()
8686
for {
8787
select {
88-
case <-stop.Done():
88+
case <-stop:
8989
logFields := logrus.WithFields(logrus.Fields{
9090
"address": address,
9191
"original": original,

cmd/manager/main.go

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"context"
2121
"flag"
22-
"net/http"
2322
"runtime"
2423
"strings"
2524

@@ -29,22 +28,18 @@ import (
2928
sdkVersion "github.com/operator-framework/operator-sdk/version"
3029
"github.com/sirupsen/logrus"
3130
"github.com/spf13/pflag"
32-
corev1 "k8s.io/api/core/v1"
3331
"k8s.io/apimachinery/pkg/api/meta"
34-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35-
runtimeutil "k8s.io/apimachinery/pkg/util/runtime"
3632
"sigs.k8s.io/controller-runtime/pkg/webhook"
3733

38-
apiruntime "k8s.io/apimachinery/pkg/runtime"
3934
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
4035
_ "k8s.io/client-go/plugin/pkg/client/auth"
4136
"k8s.io/client-go/rest"
4237
"sigs.k8s.io/controller-runtime/pkg/cache"
4338
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4439
"sigs.k8s.io/controller-runtime/pkg/client/config"
45-
"sigs.k8s.io/controller-runtime/pkg/log"
4640
"sigs.k8s.io/controller-runtime/pkg/manager"
47-
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
41+
"sigs.k8s.io/controller-runtime/pkg/runtime/log"
42+
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
4843

4944
"github.com/chaosblade-io/chaosblade-operator/channel"
5045
"github.com/chaosblade-io/chaosblade-operator/pkg/apis"
@@ -92,7 +87,7 @@ func main() {
9287
if err != nil {
9388
logrus.Fatalf("Get apiserver config error, %v", err)
9489
}
95-
err = leader.Become(context.Background(), "chaosblade-operator-lock")
90+
err = leader.Become(context.TODO(), "chaosblade-operator-lock")
9691
if err != nil {
9792
logrus.Fatalf("Become leader error, %v", err)
9893
}
@@ -138,53 +133,38 @@ func initLogger() {
138133
}
139134

140135
func addWebhook(m manager.Manager) error {
141-
server := webhook.NewServer(webhook.Options{
136+
hookServer := &webhook.Server{
142137
Port: webhookcfg.Port,
143-
})
144-
if err := m.Add(server); err != nil {
138+
}
139+
if err := m.Add(hookServer); err != nil {
145140
return err
146141
}
147142
logrus.Infof("registering %s to the webhook server", "mutating-pods")
148-
server.Register("/mutating-pods", &webhook.Admission{Handler: &mutator.Mutator{}})
143+
hookServer.Register("/mutating-pods", &webhook.Admission{Handler: &mutator.Mutator{}})
149144
return nil
150145
}
151146

152147
// createManager supports multi namespaces configuration
153148
func createManager(cfg *rest.Config) (manager.Manager, error) {
154-
scheme := apiruntime.NewScheme()
155-
runtimeutil.Must(metav1.AddMetaToScheme(scheme))
156-
runtimeutil.Must(corev1.AddToScheme(scheme))
157-
runtimeutil.Must(apis.AddToScheme(scheme))
158149
watchNamespace, err := k8sutil.GetWatchNamespace()
159150
if err != nil {
160151
return nil, err
161152
}
162153
logrus.Infof("Get watch namespace is %s", watchNamespace)
163154
if strings.Contains(watchNamespace, ",") {
164-
defaultNsps := make(map[string]cache.Config)
165-
for _, nsp := range strings.Split(watchNamespace, ",") {
166-
defaultNsps[nsp] = cache.Config{}
167-
}
155+
namespaces := strings.Split(watchNamespace, ",")
168156
return manager.New(cfg, manager.Options{
169-
Cache: cache.Options{
170-
Scheme: scheme,
171-
DefaultNamespaces: defaultNsps,
172-
},
173-
Scheme: scheme,
174-
MapperProvider: func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
175-
return apiutil.NewDynamicRESTMapper(c, httpClient)
157+
NewCache: cache.MultiNamespacedCacheBuilder(namespaces),
158+
MapperProvider: func(c *rest.Config) (meta.RESTMapper, error) {
159+
return apiutil.NewDynamicRESTMapper(c)
176160
},
177161
NewClient: channel.NewClientFunc(),
178162
})
179163
}
180164
return manager.New(cfg, manager.Options{
181-
Cache: cache.Options{
182-
Scheme: scheme,
183-
DefaultNamespaces: map[string]cache.Config{watchNamespace: {}},
184-
},
185-
Scheme: scheme,
186-
MapperProvider: func(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
187-
return apiutil.NewDynamicRESTMapper(c, httpClient)
165+
Namespace: watchNamespace,
166+
MapperProvider: func(c *rest.Config) (meta.RESTMapper, error) {
167+
return apiutil.NewDynamicRESTMapper(c)
188168
},
189169
NewClient: channel.NewClientFunc(),
190170
})

go.mod

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,34 @@ require (
77
github.com/chaosblade-io/chaosblade-exec-os v1.8.0
88
github.com/chaosblade-io/chaosblade-spec-go v1.8.0
99
github.com/ethercflow/hookfs v0.3.0
10+
github.com/go-openapi/spec v0.19.4
1011
github.com/hanwen/go-fuse v1.0.0
1112
github.com/operator-framework/operator-sdk v0.17.0
1213
github.com/sirupsen/logrus v1.8.1
1314
github.com/spf13/pflag v1.0.5
14-
k8s.io/api v0.31.0
15-
k8s.io/apimachinery v0.31.0
15+
k8s.io/api v0.20.6
16+
k8s.io/apimachinery v0.20.6
1617
k8s.io/client-go v12.0.0+incompatible
17-
sigs.k8s.io/controller-runtime v0.19.4
18+
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
19+
sigs.k8s.io/controller-runtime v0.6.0
1820
)
1921

2022
require (
23+
cloud.google.com/go v0.54.0 // indirect
24+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
25+
github.com/Azure/go-autorest/autorest v0.11.1 // indirect
26+
github.com/Azure/go-autorest/autorest/adal v0.9.5 // indirect
27+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
28+
github.com/Azure/go-autorest/logger v0.2.0 // indirect
29+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
2130
github.com/Microsoft/go-winio v0.4.17 // indirect
2231
github.com/Microsoft/hcsshim v0.8.21 // indirect
32+
github.com/PuerkitoBio/purell v1.1.1 // indirect
33+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
2334
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
2435
github.com/beorn7/perks v1.0.1 // indirect
2536
github.com/bits-and-blooms/bitset v1.2.0 // indirect
26-
github.com/cespare/xxhash/v2 v2.3.0 // indirect
37+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
2738
github.com/cilium/ebpf v0.6.2 // indirect
2839
github.com/containerd/cgroups v1.0.2-0.20210605143700-23b51209bf7b // indirect
2940
github.com/containerd/containerd v1.5.6 // indirect
@@ -32,94 +43,86 @@ require (
3243
github.com/containerd/ttrpc v1.0.2 // indirect
3344
github.com/containerd/typeurl v1.0.2 // indirect
3445
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
35-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
46+
github.com/davecgh/go-spew v1.1.1 // indirect
3647
github.com/dimchansky/utfbom v1.1.1 // indirect
3748
github.com/docker/distribution v2.7.1+incompatible // indirect
3849
github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce // indirect
3950
github.com/docker/go-connections v0.4.0 // indirect
4051
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
4152
github.com/docker/go-units v0.4.0 // indirect
42-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
43-
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
44-
github.com/fsnotify/fsnotify v1.7.0 // indirect
45-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
46-
github.com/go-logr/logr v1.4.2 // indirect
47-
github.com/go-logr/zapr v1.3.0 // indirect
53+
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 // indirect
54+
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
55+
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
56+
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
57+
github.com/go-logr/logr v0.2.1 // indirect
58+
github.com/go-logr/zapr v0.2.0 // indirect
4859
github.com/go-ole/go-ole v1.2.6 // indirect
49-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
50-
github.com/go-openapi/jsonreference v0.20.2 // indirect
51-
github.com/go-openapi/swag v0.22.4 // indirect
60+
github.com/go-openapi/jsonpointer v0.19.3 // indirect
61+
github.com/go-openapi/jsonreference v0.19.3 // indirect
62+
github.com/go-openapi/swag v0.19.5 // indirect
5263
github.com/godbus/dbus/v5 v5.0.4 // indirect
5364
github.com/gogo/googleapis v1.4.0 // indirect
5465
github.com/gogo/protobuf v1.3.2 // indirect
55-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
56-
github.com/golang/protobuf v1.5.4 // indirect
66+
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
67+
github.com/golang/protobuf v1.5.0 // indirect
5768
github.com/goodhosts/hostsfile v0.1.6 // indirect
58-
github.com/google/gnostic-models v0.6.8 // indirect
59-
github.com/google/go-cmp v0.6.0 // indirect
60-
github.com/google/gofuzz v1.2.0 // indirect
61-
github.com/google/uuid v1.6.0 // indirect
62-
github.com/gorilla/websocket v1.5.0 // indirect
69+
github.com/google/go-cmp v0.5.6 // indirect
70+
github.com/google/gofuzz v1.1.0 // indirect
71+
github.com/google/uuid v1.2.0 // indirect
72+
github.com/googleapis/gnostic v0.4.1 // indirect
73+
github.com/hashicorp/golang-lru v0.5.3 // indirect
6374
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
6475
github.com/imdario/mergo v0.3.12 // indirect
65-
github.com/josharian/intern v1.0.0 // indirect
66-
github.com/json-iterator/go v1.1.12 // indirect
76+
github.com/json-iterator/go v1.1.10 // indirect
6777
github.com/klauspost/compress v1.11.13 // indirect
6878
github.com/magefile/mage v1.15.0 // indirect
69-
github.com/mailru/easyjson v0.7.7 // indirect
79+
github.com/mailru/easyjson v0.7.0 // indirect
80+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
7081
github.com/moby/locker v1.0.1 // indirect
71-
github.com/moby/spdystream v0.4.0 // indirect
7282
github.com/moby/sys/mountinfo v0.4.1 // indirect
7383
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
74-
github.com/modern-go/reflect2 v1.0.2 // indirect
75-
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
76-
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
84+
github.com/modern-go/reflect2 v1.0.1 // indirect
7785
github.com/opencontainers/go-digest v1.0.0 // indirect
7886
github.com/opencontainers/image-spec v1.0.1 // indirect
7987
github.com/opencontainers/runc v1.0.2 // indirect
8088
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
8189
github.com/opencontainers/selinux v1.8.2 // indirect
8290
github.com/pkg/errors v0.9.1 // indirect
83-
github.com/prometheus/client_golang v1.19.1 // indirect
84-
github.com/prometheus/client_model v0.6.1 // indirect
85-
github.com/prometheus/common v0.55.0 // indirect
86-
github.com/prometheus/procfs v0.15.1 // indirect
91+
github.com/prometheus/client_golang v1.7.1 // indirect
92+
github.com/prometheus/client_model v0.2.0 // indirect
93+
github.com/prometheus/common v0.10.0 // indirect
94+
github.com/prometheus/procfs v0.6.0 // indirect
8795
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
8896
github.com/tklauser/go-sysconf v0.3.9 // indirect
8997
github.com/tklauser/numcpus v0.3.0 // indirect
90-
github.com/x448/float16 v0.8.4 // indirect
9198
github.com/yusufpapurcu/wmi v1.2.4 // indirect
9299
go.opencensus.io v0.22.3 // indirect
100+
go.uber.org/atomic v1.6.0 // indirect
93101
go.uber.org/automaxprocs v1.6.0 // indirect
94-
go.uber.org/multierr v1.11.0 // indirect
95-
go.uber.org/zap v1.26.0 // indirect
96-
golang.org/x/crypto v0.24.0 // indirect
97-
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
98-
golang.org/x/net v0.26.0 // indirect
99-
golang.org/x/oauth2 v0.21.0 // indirect
100-
golang.org/x/sync v0.7.0 // indirect
101-
golang.org/x/sys v0.21.0 // indirect
102-
golang.org/x/term v0.21.0 // indirect
103-
golang.org/x/text v0.16.0 // indirect
104-
golang.org/x/time v0.3.0 // indirect
105-
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
102+
go.uber.org/multierr v1.5.0 // indirect
103+
go.uber.org/zap v1.14.1 // indirect
104+
golang.org/x/crypto v0.1.0 // indirect
105+
golang.org/x/net v0.1.0 // indirect
106+
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
107+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
108+
golang.org/x/sys v0.1.0 // indirect
109+
golang.org/x/term v0.1.0 // indirect
110+
golang.org/x/text v0.4.0 // indirect
111+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
112+
gomodules.xyz/jsonpatch/v2 v2.0.1 // indirect
113+
google.golang.org/appengine v1.6.5 // indirect
106114
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
107-
google.golang.org/grpc v1.65.0 // indirect
108-
google.golang.org/protobuf v1.34.2 // indirect
115+
google.golang.org/grpc v1.39.0 // indirect
116+
google.golang.org/protobuf v1.26.0 // indirect
117+
gopkg.in/fsnotify.v1 v1.4.7 // indirect
109118
gopkg.in/inf.v0 v0.9.1 // indirect
110119
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
111120
gopkg.in/yaml.v2 v2.4.0 // indirect
112-
gopkg.in/yaml.v3 v3.0.1 // indirect
113121
k8s.io/klog v1.0.0 // indirect
114-
k8s.io/klog/v2 v2.130.1 // indirect
115-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
116-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
117-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
118-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
119-
sigs.k8s.io/yaml v1.4.0 // indirect
122+
k8s.io/klog/v2 v2.4.0 // indirect
123+
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
124+
sigs.k8s.io/structured-merge-diff/v4 v4.0.3 // indirect
125+
sigs.k8s.io/yaml v1.2.0 // indirect
120126
)
121127

122-
replace (
123-
k8s.io/client-go => k8s.io/client-go v0.31.0
124-
k8s.io/client-go/kubernetes/scheme => k8s.io/client-go/kubernetes/scheme v0.31.0
125-
)
128+
replace k8s.io/client-go => k8s.io/client-go v0.20.6 // Required by prometheus-operator

0 commit comments

Comments
 (0)