diff --git a/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml b/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml index d70e924ef..daed5f74b 100644 --- a/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml +++ b/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml @@ -523,10 +523,10 @@ spec: phase: description: Phase represents the current phase of the migration operation. enum: - - New + - Pending - FailedValidation - - WaitingForSource - - InProgress + - BackupInProgress + - RestoreInProgress - Completed - Failed type: string diff --git a/pkg/apis/backups/v1alpha1/migrate_type.go b/pkg/apis/backups/v1alpha1/migrate_type.go index a64dac906..e0bffd8ba 100644 --- a/pkg/apis/backups/v1alpha1/migrate_type.go +++ b/pkg/apis/backups/v1alpha1/migrate_type.go @@ -90,7 +90,7 @@ type MigratePolicy struct { } // MigratePhase is a string representation of the lifecycle phase of a Migrate instance -// +kubebuilder:validation:Enum=New;FailedValidation;WaitingForSource;InProgress;Completed;Failed +// +kubebuilder:validation:Enum=Pending;FailedValidation;BackupInProgress;RestoreInProgress;Completed;Failed type MigratePhase string const ( diff --git a/pkg/client-go/generated/clientset/versioned/clientset.go b/pkg/client-go/generated/clientset/versioned/clientset.go index eae9f08af..676ecb884 100644 --- a/pkg/client-go/generated/clientset/versioned/clientset.go +++ b/pkg/client-go/generated/clientset/versioned/clientset.go @@ -41,7 +41,8 @@ type Interface interface { InfrastructureV1alpha1() infrastructurev1alpha1.InfrastructureV1alpha1Interface } -// Clientset contains the clients for groups. +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient appsV1alpha1 *appsv1alpha1.AppsV1alpha1Client diff --git a/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go b/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go index c1072cde2..8cdde4acf 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go +++ b/pkg/client-go/generated/clientset/versioned/typed/apps/v1alpha1/fake/fake_application.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeApplications struct { ns string } -var applicationsResource = v1alpha1.SchemeGroupVersion.WithResource("applications") +var applicationsResource = schema.GroupVersionResource{Group: "apps.kurator.dev", Version: "v1alpha1", Resource: "applications"} -var applicationsKind = v1alpha1.SchemeGroupVersion.WithKind("Application") +var applicationsKind = schema.GroupVersionKind{Group: "apps.kurator.dev", Version: "v1alpha1", Kind: "Application"} // Get takes name of the application, and returns the corresponding application object, and an error if there is any. func (c *FakeApplications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Application, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go b/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go index 9c11871eb..401caad12 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go +++ b/pkg/client-go/generated/clientset/versioned/typed/backups/v1alpha1/fake/fake_backup.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeBackups struct { ns string } -var backupsResource = v1alpha1.SchemeGroupVersion.WithResource("backups") +var backupsResource = schema.GroupVersionResource{Group: "backup.kurator.dev", Version: "v1alpha1", Resource: "backups"} -var backupsKind = v1alpha1.SchemeGroupVersion.WithKind("Backup") +var backupsKind = schema.GroupVersionKind{Group: "backup.kurator.dev", Version: "v1alpha1", Kind: "Backup"} // Get takes name of the backup, and returns the corresponding backup object, and an error if there is any. func (c *FakeBackups) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Backup, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go index a0c3092f9..4d6d3b39d 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_attachedcluster.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeAttachedClusters struct { ns string } -var attachedclustersResource = v1alpha1.SchemeGroupVersion.WithResource("attachedclusters") +var attachedclustersResource = schema.GroupVersionResource{Group: "cluster.kurator.dev", Version: "v1alpha1", Resource: "attachedclusters"} -var attachedclustersKind = v1alpha1.SchemeGroupVersion.WithKind("AttachedCluster") +var attachedclustersKind = schema.GroupVersionKind{Group: "cluster.kurator.dev", Version: "v1alpha1", Kind: "AttachedCluster"} // Get takes name of the attachedCluster, and returns the corresponding attachedCluster object, and an error if there is any. func (c *FakeAttachedClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.AttachedCluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go index ee31f8d55..5715a0c42 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/cluster/v1alpha1/fake/fake_cluster.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeClusters struct { ns string } -var clustersResource = v1alpha1.SchemeGroupVersion.WithResource("clusters") +var clustersResource = schema.GroupVersionResource{Group: "cluster.kurator.dev", Version: "v1alpha1", Resource: "clusters"} -var clustersKind = v1alpha1.SchemeGroupVersion.WithKind("Cluster") +var clustersKind = schema.GroupVersionKind{Group: "cluster.kurator.dev", Version: "v1alpha1", Kind: "Cluster"} // Get takes name of the cluster, and returns the corresponding cluster object, and an error if there is any. func (c *FakeClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Cluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go b/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go index 45b7087e4..44959a50e 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go +++ b/pkg/client-go/generated/clientset/versioned/typed/fleet/v1alpha1/fake/fake_fleet.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeFleets struct { ns string } -var fleetsResource = v1alpha1.SchemeGroupVersion.WithResource("fleets") +var fleetsResource = schema.GroupVersionResource{Group: "fleet.kurator.dev", Version: "v1alpha1", Resource: "fleets"} -var fleetsKind = v1alpha1.SchemeGroupVersion.WithKind("Fleet") +var fleetsKind = schema.GroupVersionKind{Group: "fleet.kurator.dev", Version: "v1alpha1", Kind: "Fleet"} // Get takes name of the fleet, and returns the corresponding fleet object, and an error if there is any. func (c *FakeFleets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Fleet, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go index d1758b930..d9b441fce 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go +++ b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_customcluster.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeCustomClusters struct { ns string } -var customclustersResource = v1alpha1.SchemeGroupVersion.WithResource("customclusters") +var customclustersResource = schema.GroupVersionResource{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Resource: "customclusters"} -var customclustersKind = v1alpha1.SchemeGroupVersion.WithKind("CustomCluster") +var customclustersKind = schema.GroupVersionKind{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Kind: "CustomCluster"} // Get takes name of the customCluster, and returns the corresponding customCluster object, and an error if there is any. func (c *FakeCustomClusters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomCluster, err error) { diff --git a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go index aeb567b06..8851192e6 100644 --- a/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go +++ b/pkg/client-go/generated/clientset/versioned/typed/infra/v1alpha1/fake/fake_custommachine.go @@ -23,6 +23,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +36,9 @@ type FakeCustomMachines struct { ns string } -var custommachinesResource = v1alpha1.SchemeGroupVersion.WithResource("custommachines") +var custommachinesResource = schema.GroupVersionResource{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Resource: "custommachines"} -var custommachinesKind = v1alpha1.SchemeGroupVersion.WithKind("CustomMachine") +var custommachinesKind = schema.GroupVersionKind{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1", Kind: "CustomMachine"} // Get takes name of the customMachine, and returns the corresponding customMachine object, and an error if there is any. func (c *FakeCustomMachines) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CustomMachine, err error) { diff --git a/pkg/client-go/generated/informers/externalversions/factory.go b/pkg/client-go/generated/informers/externalversions/factory.go index 32f3ec94e..6eb2b2217 100644 --- a/pkg/client-go/generated/informers/externalversions/factory.go +++ b/pkg/client-go/generated/informers/externalversions/factory.go @@ -51,11 +51,6 @@ type sharedInformerFactory struct { // startedInformers is used for tracking which informers have been started. // This allows Start() to be called multiple times safely. startedInformers map[reflect.Type]bool - // wg tracks how many goroutines were started. - wg sync.WaitGroup - // shuttingDown is true when Shutdown has been called. It may still be running - // because it needs to wait for goroutines. - shuttingDown bool } // WithCustomResyncConfig sets a custom resync period for the specified informer types. @@ -116,39 +111,20 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy return factory } +// Start initializes all requested informers. func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { f.lock.Lock() defer f.lock.Unlock() - if f.shuttingDown { - return - } - for informerType, informer := range f.informers { if !f.startedInformers[informerType] { - f.wg.Add(1) - // We need a new variable in each loop iteration, - // otherwise the goroutine would use the loop variable - // and that keeps changing. - informer := informer - go func() { - defer f.wg.Done() - informer.Run(stopCh) - }() + go informer.Run(stopCh) f.startedInformers[informerType] = true } } } -func (f *sharedInformerFactory) Shutdown() { - f.lock.Lock() - f.shuttingDown = true - f.lock.Unlock() - - // Will return immediately if there is nothing to wait for. - f.wg.Wait() -} - +// WaitForCacheSync waits for all started informers' cache were synced. func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { informers := func() map[reflect.Type]cache.SharedIndexInformer { f.lock.Lock() @@ -170,7 +146,7 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref return res } -// InformerFor returns the SharedIndexInformer for obj using an internal +// InternalInformerFor returns the SharedIndexInformer for obj using an internal // client. func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { f.lock.Lock() @@ -195,57 +171,10 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal // SharedInformerFactory provides shared informers for resources in all known // API group versions. -// -// It is typically used like this: -// -// ctx, cancel := context.Background() -// defer cancel() -// factory := NewSharedInformerFactory(client, resyncPeriod) -// defer factory.WaitForStop() // Returns immediately if nothing was started. -// genericInformer := factory.ForResource(resource) -// typedInformer := factory.SomeAPIGroup().V1().SomeType() -// factory.Start(ctx.Done()) // Start processing these informers. -// synced := factory.WaitForCacheSync(ctx.Done()) -// for v, ok := range synced { -// if !ok { -// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) -// return -// } -// } -// -// // Creating informers can also be created after Start, but then -// // Start must be called again: -// anotherGenericInformer := factory.ForResource(resource) -// factory.Start(ctx.Done()) type SharedInformerFactory interface { internalinterfaces.SharedInformerFactory - - // Start initializes all requested informers. They are handled in goroutines - // which run until the stop channel gets closed. - Start(stopCh <-chan struct{}) - - // Shutdown marks a factory as shutting down. At that point no new - // informers can be started anymore and Start will return without - // doing anything. - // - // In addition, Shutdown blocks until all goroutines have terminated. For that - // to happen, the close channel(s) that they were started with must be closed, - // either before Shutdown gets called or while it is waiting. - // - // Shutdown may be called multiple times, even concurrently. All such calls will - // block until all goroutines have terminated. - Shutdown() - - // WaitForCacheSync blocks until all started informers' caches were synced - // or the stop channel gets closed. - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - // ForResource gives generic access to a shared informer of the matching type. ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - - // InformerFor returns the SharedIndexInformer for obj using an internal - // client. - InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Apps() apps.Interface Backup() backups.Interface