Skip to content
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.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else
endif
endif

RESTIC_VER := 0.17.3
RESTIC_VER := 0.18.1

###
### These variables should not need tweaking.
Expand Down
317 changes: 177 additions & 140 deletions go.mod

Large diffs are not rendered by default.

1,428 changes: 443 additions & 985 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/backup/backupsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type BackupSessionController struct {
InvokerName string
Namespace string
// Backup Session
bsQueue *queue.Worker
bsQueue *queue.Worker[any]
bsInformer cache.SharedIndexInformer
bsLister v1beta1.BackupSessionLister

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

func (c *BackupSessionController) initBackupSessionWatcher() error {
c.bsInformer = c.StashInformerFactory.Stash().V1beta1().BackupSessions().Informer()
c.bsQueue = queue.New(api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSession)
c.bsQueue = queue.New[any](api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSession)
_, _ = c.bsInformer.AddEventHandler(queue.NewFilteredHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj any) {
if backupsession, ok := obj.(*api_v1beta1.BackupSession); ok && c.selectedByLabels(backupsession) {
Expand Down Expand Up @@ -164,7 +164,8 @@ func (c *BackupSessionController) initBackupSessionWatcher() error {
// syncToStdout is the business logic of the controller. In this controller it simply prints
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
// The retry logic should not be part of the business logic.
func (c *BackupSessionController) processBackupSession(key string) error {
func (c *BackupSessionController) processBackupSession(v any) error {
key := v.(string)
obj, exists, err := c.bsInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.Errorf("Fetching object with key %s from store failed with %v", key, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmds/create_volumesnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"stash.appscode.dev/stash/pkg/status"
"stash.appscode.dev/stash/pkg/volumesnapshot"

vsapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
vscs "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned"
vsapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
vscs "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
"github.com/spf13/cobra"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmds/restore_volumesnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"stash.appscode.dev/stash/pkg/status"
"stash.appscode.dev/stash/pkg/util"

vscs "github.com/kubernetes-csi/external-snapshotter/client/v7/clientset/versioned"
vscs "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
"github.com/spf13/cobra"
"gomodules.xyz/pointer"
core "k8s.io/api/core/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func NewRootCmd() *cobra.Command {
}

rootCmd.AddCommand(v.NewCmdVersion())
stopCh := genericapiserver.SetupSignalHandler()
rootCmd.AddCommand(NewCmdRun(os.Stdout, os.Stderr, stopCh))
ctx := genericapiserver.SetupSignalContext()
rootCmd.AddCommand(NewCmdRun(ctx, os.Stdout, os.Stderr))

rootCmd.AddCommand(NewCmdSnapshots())
rootCmd.AddCommand(NewCmdForget())
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmds/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cmds

import (
"context"
"io"

"stash.appscode.dev/stash/pkg/cmds/server"
Expand All @@ -26,7 +27,7 @@ import (
"k8s.io/klog/v2"
)

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

cmd := &cobra.Command{
Expand All @@ -43,7 +44,7 @@ func NewCmdRun(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
if err := o.Validate(args); err != nil {
return err
}
if err := o.Run(stopCh); err != nil {
if err := o.Run(ctx); err != nil {
return err
}
return nil
Expand Down
13 changes: 7 additions & 6 deletions pkg/cmds/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package server

import (
"context"
"fmt"
"io"
"net"
Expand All @@ -30,10 +31,9 @@ import (
admissionv1beta1 "k8s.io/api/admission/v1beta1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
"k8s.io/apiserver/pkg/features"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
"k8s.io/apiserver/pkg/util/feature"
basecompatibility "k8s.io/component-base/compatibility"
"kmodules.xyz/client-go/tools/clientcmd"
)

Expand All @@ -48,7 +48,6 @@ type StashOptions struct {
}

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

serverConfig.EffectiveVersion = basecompatibility.NewEffectiveVersionFromString("v1.0.0", "", "")

serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(v1alpha1.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(server.Scheme))
serverConfig.OpenAPIConfig.Info.Title = "stash-webhook-server"
serverConfig.OpenAPIConfig.Info.Version = v1alpha1.SchemeGroupVersion.Version
Expand All @@ -131,7 +132,7 @@ func (o StashOptions) Config() (*server.StashConfig, error) {
return config, nil
}

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

// Start periodic license verification
//nolint:errcheck
go licenseEnforcer.VerifyLicensePeriodically(config.ExtraConfig.ClientConfig, o.ExtraOptions.LicenseFile, stopCh)
go licenseEnforcer.VerifyLicensePeriodically(config.ExtraConfig.ClientConfig, o.ExtraOptions.LicenseFile, ctx.Done())

return s.Run(stopCh)
return s.Run(ctx)
}
5 changes: 3 additions & 2 deletions pkg/controller/backup_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *StashController) validateBackupConfiguration(bc *api_v1beta1.BackupConf

func (c *StashController) initBackupConfigurationWatcher() {
c.bcInformer = c.stashInformerFactory.Stash().V1beta1().BackupConfigurations().Informer()
c.bcQueue = queue.New(api_v1beta1.ResourceKindBackupConfiguration, c.MaxNumRequeues, c.NumThreads, c.runBackupConfigurationProcessor)
c.bcQueue = queue.New[any](api_v1beta1.ResourceKindBackupConfiguration, c.MaxNumRequeues, c.NumThreads, c.runBackupConfigurationProcessor)
if c.auditor != nil {
c.auditor.ForGVK(c.bcInformer, api_v1beta1.SchemeGroupVersion.WithKind(api_v1beta1.ResourceKindBackupConfiguration))
}
Expand All @@ -130,7 +130,8 @@ func (c *StashController) initBackupConfigurationWatcher() {
// syncToStdout is the business logic of the controller. In this controller it simply prints
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
// The retry logic should not be part of the business logic.
func (c *StashController) runBackupConfigurationProcessor(key string) error {
func (c *StashController) runBackupConfigurationProcessor(v any) error {
key := v.(string)
obj, exists, err := c.bcInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/backup_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ func (c *StashController) NewBackupSessionWebhook() hooks.AdmissionHook {

func (c *StashController) initBackupSessionWatcher() {
c.backupSessionInformer = c.stashInformerFactory.Stash().V1beta1().BackupSessions().Informer()
c.backupSessionQueue = queue.New(api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSessionEvent)
c.backupSessionQueue = queue.New[any](api_v1beta1.ResourceKindBackupSession, c.MaxNumRequeues, c.NumThreads, c.processBackupSessionEvent)
if c.auditor != nil {
c.auditor.ForGVK(c.backupSessionInformer, api_v1beta1.SchemeGroupVersion.WithKind(api_v1beta1.ResourceKindBackupSession))
}
_, _ = c.backupSessionInformer.AddEventHandler(queue.DefaultEventHandler(c.backupSessionQueue.GetQueue(), core.NamespaceAll))
c.backupSessionLister = c.stashInformerFactory.Stash().V1beta1().BackupSessions().Lister()
}

func (c *StashController) processBackupSessionEvent(key string) error {
func (c *StashController) processBackupSessionEvent(v any) error {
key := v.(string)
obj, exists, err := c.backupSessionInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,47 @@ type StashController struct {
stashInformerFactory stashinformers.SharedInformerFactory

// Repository
repoQueue *queue.Worker
repoQueue *queue.Worker[any]
repoInformer cache.SharedIndexInformer
repoLister stash_listers.RepositoryLister

// Deployment
dpQueue *queue.Worker
dpQueue *queue.Worker[any]
dpInformer cache.SharedIndexInformer
dpLister apps_listers.DeploymentLister

// DaemonSet
dsQueue *queue.Worker
dsQueue *queue.Worker[any]
dsInformer cache.SharedIndexInformer
dsLister apps_listers.DaemonSetLister

// StatefulSet
ssQueue *queue.Worker
ssQueue *queue.Worker[any]
ssInformer cache.SharedIndexInformer
ssLister apps_listers.StatefulSetLister

// Job
jobQueue *queue.Worker
jobQueue *queue.Worker[any]
jobInformer cache.SharedIndexInformer
jobLister batch_listers.JobLister

// BackupConfiguration
bcQueue *queue.Worker
bcQueue *queue.Worker[any]
bcInformer cache.SharedIndexInformer
bcLister stash_listers_v1beta1.BackupConfigurationLister

// BackupSession
backupSessionQueue *queue.Worker
backupSessionQueue *queue.Worker[any]
backupSessionInformer cache.SharedIndexInformer
backupSessionLister stash_listers_v1beta1.BackupSessionLister

// RestoreSession
restoreSessionQueue *queue.Worker
restoreSessionQueue *queue.Worker[any]
restoreSessionInformer cache.SharedIndexInformer
restoreSessionLister stash_listers_v1beta1.RestoreSessionLister

// Openshift DeploymentConfiguration
dcQueue *queue.Worker
dcQueue *queue.Worker[any]
dcInformer cache.SharedIndexInformer
dcLister oc_listers.DeploymentConfigLister
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/daemonsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ func (c *StashController) NewDaemonSetWebhook() hooks.AdmissionHook {

func (c *StashController) initDaemonSetWatcher() {
c.dsInformer = c.kubeInformerFactory.Apps().V1().DaemonSets().Informer()
c.dsQueue = queue.New("DaemonSet", c.MaxNumRequeues, c.NumThreads, c.processDaemonSetEvent)
c.dsQueue = queue.New[any]("DaemonSet", c.MaxNumRequeues, c.NumThreads, c.processDaemonSetEvent)
_, _ = c.dsInformer.AddEventHandler(queue.DefaultEventHandler(c.dsQueue.GetQueue(), core.NamespaceAll))
c.dsLister = c.kubeInformerFactory.Apps().V1().DaemonSets().Lister()
}

// syncToStdout is the business logic of the controller. In this controller it simply prints
// information about the daemonset to stdout. In case an error happened, it has to simply return the error.
// The retry logic should not be part of the business logic.
func (c *StashController) processDaemonSetEvent(key string) error {
func (c *StashController) processDaemonSetEvent(v any) error {
key := v.(string)
obj, exists, err := c.dsInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ func (c *StashController) NewDeploymentWebhook() hooks.AdmissionHook {

func (c *StashController) initDeploymentWatcher() {
c.dpInformer = c.kubeInformerFactory.Apps().V1().Deployments().Informer()
c.dpQueue = queue.New("Deployment", c.MaxNumRequeues, c.NumThreads, c.processDeploymentEvent)
c.dpQueue = queue.New[any]("Deployment", c.MaxNumRequeues, c.NumThreads, c.processDeploymentEvent)
_, _ = c.dpInformer.AddEventHandler(queue.DefaultEventHandler(c.dpQueue.GetQueue(), core.NamespaceAll))
c.dpLister = c.kubeInformerFactory.Apps().V1().Deployments().Lister()
}

func (c *StashController) processDeploymentEvent(key string) error {
func (c *StashController) processDeploymentEvent(v any) error {
key := v.(string)
obj, exists, err := c.dpInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/deploymentconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ func (c *StashController) initDeploymentConfigWatcher() {
return
}
c.dcInformer = c.ocInformerFactory.Apps().V1().DeploymentConfigs().Informer()
c.dcQueue = queue.New(apis.KindDeploymentConfig, c.MaxNumRequeues, c.NumThreads, c.processDeploymentConfigEvent)
c.dcQueue = queue.New[any](apis.KindDeploymentConfig, c.MaxNumRequeues, c.NumThreads, c.processDeploymentConfigEvent)
_, _ = c.dcInformer.AddEventHandler(queue.DefaultEventHandler(c.dcQueue.GetQueue(), core.NamespaceAll))
c.dcLister = c.ocInformerFactory.Apps().V1().DeploymentConfigs().Lister()
}

// syncToStdout is the business logic of the controller. In this controller it simply prints
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
// The retry logic should not be part of the business logic.
func (c *StashController) processDeploymentConfigEvent(key string) error {
func (c *StashController) processDeploymentConfigEvent(v any) error {
key := v.(string)
obj, exists, err := c.dcInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ func (c *StashController) initJobWatcher() {
},
)
})
c.jobQueue = queue.New("Job", c.MaxNumRequeues, c.NumThreads, c.runJobInjector)
c.jobQueue = queue.New[any]("Job", c.MaxNumRequeues, c.NumThreads, c.runJobInjector)
_, _ = c.jobInformer.AddEventHandler(queue.DefaultEventHandler(c.jobQueue.GetQueue(), core.NamespaceAll))
c.jobLister = c.kubeInformerFactory.Batch().V1().Jobs().Lister()
}

func (c *StashController) runJobInjector(key string) error {
func (c *StashController) runJobInjector(v any) error {
key := v.(string)
obj, exists, err := c.jobInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"k8s.io/klog/v2"
core_util "kmodules.xyz/client-go/core/v1"
"kmodules.xyz/client-go/tools/queue"
"kmodules.xyz/objectstore-api/osm"
"kmodules.xyz/objectstore-api/pkg/osm"
"kmodules.xyz/webhook-runtime/admission"
hooks "kmodules.xyz/webhook-runtime/admission/v1beta1"
webhook "kmodules.xyz/webhook-runtime/admission/v1beta1/generic"
Expand Down Expand Up @@ -73,15 +73,16 @@ func (c *StashController) NewRepositoryWebhook() hooks.AdmissionHook {

func (c *StashController) initRepositoryWatcher() {
c.repoInformer = c.stashInformerFactory.Stash().V1alpha1().Repositories().Informer()
c.repoQueue = queue.New(api_v1alpha1.ResourceKindRepository, c.MaxNumRequeues, c.NumThreads, c.runRepositoryReconciler)
c.repoQueue = queue.New[any](api_v1alpha1.ResourceKindRepository, c.MaxNumRequeues, c.NumThreads, c.runRepositoryReconciler)
if c.auditor != nil {
c.auditor.ForGVK(c.repoInformer, api_v1alpha1.SchemeGroupVersion.WithKind(api_v1alpha1.ResourceKindRepository))
}
_, _ = c.repoInformer.AddEventHandler(queue.NewReconcilableHandler(c.repoQueue.GetQueue(), core.NamespaceAll))
c.repoLister = c.stashInformerFactory.Stash().V1alpha1().Repositories().Lister()
}

func (c *StashController) runRepositoryReconciler(key string) error {
func (c *StashController) runRepositoryReconciler(v any) error {
key := v.(string)
obj, exist, err := c.repoInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/restore_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,16 @@ func (c *StashController) NewRestoreSessionMutator() hooks.AdmissionHook {
// process only add events
func (c *StashController) initRestoreSessionWatcher() {
c.restoreSessionInformer = c.stashInformerFactory.Stash().V1beta1().RestoreSessions().Informer()
c.restoreSessionQueue = queue.New(api_v1beta1.ResourceKindRestoreSession, c.MaxNumRequeues, c.NumThreads, c.processRestoreSessionEvent)
c.restoreSessionQueue = queue.New[any](api_v1beta1.ResourceKindRestoreSession, c.MaxNumRequeues, c.NumThreads, c.processRestoreSessionEvent)
if c.auditor != nil {
c.auditor.ForGVK(c.restoreSessionInformer, api_v1beta1.SchemeGroupVersion.WithKind(api_v1beta1.ResourceKindRestoreSession))
}
_, _ = c.restoreSessionInformer.AddEventHandler(queue.DefaultEventHandler(c.restoreSessionQueue.GetQueue(), core.NamespaceAll))
c.restoreSessionLister = c.stashInformerFactory.Stash().V1beta1().RestoreSessions().Lister()
}

func (c *StashController) processRestoreSessionEvent(key string) error {
func (c *StashController) processRestoreSessionEvent(v any) error {
key := v.(string)
obj, exists, err := c.restoreSessionInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/statefulsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ func (c *StashController) NewStatefulSetWebhook() hooks.AdmissionHook {

func (c *StashController) initStatefulSetWatcher() {
c.ssInformer = c.kubeInformerFactory.Apps().V1().StatefulSets().Informer()
c.ssQueue = queue.New("StatefulSet", c.MaxNumRequeues, c.NumThreads, c.processStatefulSetEvent)
c.ssQueue = queue.New[any]("StatefulSet", c.MaxNumRequeues, c.NumThreads, c.processStatefulSetEvent)
_, _ = c.ssInformer.AddEventHandler(queue.DefaultEventHandler(c.ssQueue.GetQueue(), core.NamespaceAll))
c.ssLister = c.kubeInformerFactory.Apps().V1().StatefulSets().Lister()
}

// syncToStdout is the business logic of the controller. In this controller it simply prints
// information about the deployment to stdout. In case an error happened, it has to simply return the error.
// The retry logic should not be part of the business logic.
func (c *StashController) processStatefulSetEvent(key string) error {
func (c *StashController) processStatefulSetEvent(v any) error {
key := v.(string)
obj, exists, err := c.ssInformer.GetIndexer().GetByKey(key)
if err != nil {
klog.ErrorS(err, "Failed to fetch object from indexer",
Expand Down
2 changes: 1 addition & 1 deletion pkg/rbac/volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
api_v1alpha1 "stash.appscode.dev/apimachinery/apis/stash/v1alpha1"
api_v1beta1 "stash.appscode.dev/apimachinery/apis/stash/v1beta1"

vsapi "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
vsapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
rbac "k8s.io/api/rbac/v1"
Expand Down
Loading
Loading