Skip to content

Commit 7783500

Browse files
committed
Use k8s 1.34 client libs
/cherry-pick Signed-off-by: Tamal Saha <[email protected]>
1 parent 0170699 commit 7783500

5,805 files changed

Lines changed: 572620 additions & 216024 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ else
4646
endif
4747
endif
4848

49-
RESTIC_VER := 0.17.3
49+
RESTIC_VER := 0.18.1
5050

5151
###
5252
### These variables should not need tweaking.

go.mod

Lines changed: 177 additions & 140 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 443 additions & 985 deletions
Large diffs are not rendered by default.

pkg/backup/backupsession.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type BackupSessionController struct {
7070
InvokerName string
7171
Namespace string
7272
// Backup Session
73-
bsQueue *queue.Worker
73+
bsQueue *queue.Worker[any]
7474
bsInformer cache.SharedIndexInformer
7575
bsLister v1beta1.BackupSessionLister
7676

@@ -134,7 +134,7 @@ func (c *BackupSessionController) runBackupSessionController(invokerRef *core.Ob
134134

135135
func (c *BackupSessionController) initBackupSessionWatcher() error {
136136
c.bsInformer = c.StashInformerFactory.Stash().V1beta1().BackupSessions().Informer()
137-
c.bsQueue = queue.New(api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSession)
137+
c.bsQueue = queue.New[any](api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSession)
138138
_, _ = c.bsInformer.AddEventHandler(queue.NewFilteredHandler(cache.ResourceEventHandlerFuncs{
139139
AddFunc: func(obj any) {
140140
if backupsession, ok := obj.(*api_v1beta1.BackupSession); ok && c.selectedByLabels(backupsession) {
@@ -164,7 +164,8 @@ func (c *BackupSessionController) initBackupSessionWatcher() error {
164164
// syncToStdout is the business logic of the controller. In this controller it simply prints
165165
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
166166
// The retry logic should not be part of the business logic.
167-
func (c *BackupSessionController) processBackupSession(key string) error {
167+
func (c *BackupSessionController) processBackupSession(v any) error {
168+
key := v.(string)
168169
obj, exists, err := c.bsInformer.GetIndexer().GetByKey(key)
169170
if err != nil {
170171
klog.Errorf("Fetching object with key %s from store failed with %v", key, err)

pkg/cmds/create_volumesnapshot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import (
3131
"stash.appscode.dev/stash/pkg/status"
3232
"stash.appscode.dev/stash/pkg/volumesnapshot"
3333

34-
vsapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
35-
vscs "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned"
34+
vsapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
35+
vscs "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
3636
"github.com/spf13/cobra"
3737
appsv1 "k8s.io/api/apps/v1"
3838
corev1 "k8s.io/api/core/v1"

pkg/cmds/restore_volumesnapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"stash.appscode.dev/stash/pkg/status"
3232
"stash.appscode.dev/stash/pkg/util"
3333

34-
vscs "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned"
34+
vscs "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
3535
"github.com/spf13/cobra"
3636
"gomodules.xyz/pointer"
3737
core "k8s.io/api/core/v1"

pkg/cmds/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func NewRootCmd() *cobra.Command {
4545
}
4646

4747
rootCmd.AddCommand(v.NewCmdVersion())
48-
stopCh := genericapiserver.SetupSignalHandler()
49-
rootCmd.AddCommand(NewCmdRun(os.Stdout, os.Stderr, stopCh))
48+
ctx := genericapiserver.SetupSignalContext()
49+
rootCmd.AddCommand(NewCmdRun(ctx, os.Stdout, os.Stderr))
5050

5151
rootCmd.AddCommand(NewCmdSnapshots())
5252
rootCmd.AddCommand(NewCmdForget())

pkg/cmds/run.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package cmds
1818

1919
import (
20+
"context"
2021
"io"
2122

2223
"stash.appscode.dev/stash/pkg/cmds/server"
@@ -26,7 +27,7 @@ import (
2627
"k8s.io/klog/v2"
2728
)
2829

29-
func NewCmdRun(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
30+
func NewCmdRun(ctx context.Context, out, errOut io.Writer) *cobra.Command {
3031
o := server.NewStashOptions(out, errOut)
3132

3233
cmd := &cobra.Command{
@@ -43,7 +44,7 @@ func NewCmdRun(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
4344
if err := o.Validate(args); err != nil {
4445
return err
4546
}
46-
if err := o.Run(stopCh); err != nil {
47+
if err := o.Run(ctx); err != nil {
4748
return err
4849
}
4950
return nil

pkg/cmds/server/start.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package server
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"io"
2223
"net"
@@ -30,10 +31,9 @@ import (
3031
admissionv1beta1 "k8s.io/api/admission/v1beta1"
3132
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3233
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
33-
"k8s.io/apiserver/pkg/features"
3434
genericapiserver "k8s.io/apiserver/pkg/server"
3535
genericoptions "k8s.io/apiserver/pkg/server/options"
36-
"k8s.io/apiserver/pkg/util/feature"
36+
basecompatibility "k8s.io/component-base/compatibility"
3737
"kmodules.xyz/client-go/tools/clientcmd"
3838
)
3939

@@ -48,7 +48,6 @@ type StashOptions struct {
4848
}
4949

5050
func NewStashOptions(out, errOut io.Writer) *StashOptions {
51-
_ = feature.DefaultMutableFeatureGate.Set(fmt.Sprintf("%s=false", features.APIPriorityAndFairness))
5251
o := &StashOptions{
5352
// TODO we will nil out the etcd storage options. This requires a later level of k8s.io/apiserver
5453
RecommendedOptions: genericoptions.NewRecommendedOptions(
@@ -109,6 +108,8 @@ func (o StashOptions) Config() (*server.StashConfig, error) {
109108
"/apis/admission.stash.appscode.com/v1beta1/backupconfigurationvalidators",
110109
}
111110

111+
serverConfig.EffectiveVersion = basecompatibility.NewEffectiveVersionFromString("v1.0.0", "", "")
112+
112113
serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(v1alpha1.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(server.Scheme))
113114
serverConfig.OpenAPIConfig.Info.Title = "stash-webhook-server"
114115
serverConfig.OpenAPIConfig.Info.Version = v1alpha1.SchemeGroupVersion.Version
@@ -131,7 +132,7 @@ func (o StashOptions) Config() (*server.StashConfig, error) {
131132
return config, nil
132133
}
133134

134-
func (o StashOptions) Run(stopCh <-chan struct{}) error {
135+
func (o StashOptions) Run(ctx context.Context) error {
135136
config, err := o.Config()
136137
if err != nil {
137138
return err
@@ -144,7 +145,7 @@ func (o StashOptions) Run(stopCh <-chan struct{}) error {
144145

145146
// Start periodic license verification
146147
//nolint:errcheck
147-
go licenseEnforcer.VerifyLicensePeriodically(config.ExtraConfig.ClientConfig, o.ExtraOptions.LicenseFile, stopCh)
148+
go licenseEnforcer.VerifyLicensePeriodically(config.ExtraConfig.ClientConfig, o.ExtraOptions.LicenseFile, ctx.Done())
148149

149-
return s.Run(stopCh)
150+
return s.Run(ctx)
150151
}

pkg/controller/backup_configuration.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *StashController) validateBackupConfiguration(bc *api_v1beta1.BackupConf
112112

113113
func (c *StashController) initBackupConfigurationWatcher() {
114114
c.bcInformer = c.stashInformerFactory.Stash().V1beta1().BackupConfigurations().Informer()
115-
c.bcQueue = queue.New(api_v1beta1.ResourceKindBackupConfiguration, c.MaxNumRequeues, c.NumThreads, c.runBackupConfigurationProcessor)
115+
c.bcQueue = queue.New[any](api_v1beta1.ResourceKindBackupConfiguration, c.MaxNumRequeues, c.NumThreads, c.runBackupConfigurationProcessor)
116116
if c.auditor != nil {
117117
c.auditor.ForGVK(c.bcInformer, api_v1beta1.SchemeGroupVersion.WithKind(api_v1beta1.ResourceKindBackupConfiguration))
118118
}
@@ -130,7 +130,8 @@ func (c *StashController) initBackupConfigurationWatcher() {
130130
// syncToStdout is the business logic of the controller. In this controller it simply prints
131131
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
132132
// The retry logic should not be part of the business logic.
133-
func (c *StashController) runBackupConfigurationProcessor(key string) error {
133+
func (c *StashController) runBackupConfigurationProcessor(v any) error {
134+
key := v.(string)
134135
obj, exists, err := c.bcInformer.GetIndexer().GetByKey(key)
135136
if err != nil {
136137
klog.ErrorS(err, "Failed to fetch object from indexer",

0 commit comments

Comments
 (0)