Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: filter events to reconcile by CRD API version #8521

Merged
merged 4 commits into from
Dec 2, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/apps/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// SetupWithManager sets up the controller with the Manager.
func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr, &appsv1.Cluster{}, &appsv1.Component{}).
For(&appsv1.Cluster{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: int(math.Ceil(viper.GetFloat64(constant.CfgKBReconcileWorkers) / 4)),
Expand Down
16 changes: 9 additions & 7 deletions controllers/apps/clusterdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *ClusterDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager sets up the controller with the Manager.
func (r *ClusterDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr, &appsv1.ClusterDefinition{}).
For(&appsv1.ClusterDefinition{}).
Complete(r)
}
Expand Down Expand Up @@ -367,12 +367,14 @@ func defaultClusterTopology(clusterDef *appsv1.ClusterDefinition) *appsv1.Cluste

// referredClusterTopology returns the cluster topology which has name @name.
func referredClusterTopology(clusterDef *appsv1.ClusterDefinition, name string) *appsv1.ClusterTopology {
if len(name) == 0 {
return defaultClusterTopology(clusterDef)
}
for i, topology := range clusterDef.Spec.Topologies {
if topology.Name == name {
return &clusterDef.Spec.Topologies[i]
if clusterDef != nil {
if len(name) == 0 {
return defaultClusterTopology(clusterDef)
}
for i, topology := range clusterDef.Spec.Topologies {
if topology.Name == name {
return &clusterDef.Spec.Topologies[i]
}
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions controllers/apps/component_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (r *ComponentReconciler) SetupWithManager(mgr ctrl.Manager, multiClusterMgr
}

func (r *ComponentReconciler) setupWithManager(mgr ctrl.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr, &appsv1.Component{}, &workloads.InstanceSet{}).
For(&appsv1.Component{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
Expand All @@ -222,7 +222,7 @@ func (r *ComponentReconciler) setupWithManager(mgr ctrl.Manager) error {
}

func (r *ComponentReconciler) setupWithMultiClusterManager(mgr ctrl.Manager, multiClusterMgr multicluster.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr, &appsv1.Component{}, &workloads.InstanceSet{}).
For(&appsv1.Component{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/componentdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *ComponentDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.

// SetupWithManager sets up the controller with the Manager.
func (r *ComponentDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr, &appsv1.ComponentDefinition{}).
For(&appsv1.ComponentDefinition{}).
Complete(r)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/componentversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (r *ComponentVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req

// SetupWithManager sets up the controller with the Manager.
func (r *ComponentVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr, &appsv1.ComponentVersion{}, &appsv1.ComponentDefinition{}).
For(&appsv1.ComponentVersion{}).
Watches(&appsv1.ComponentDefinition{}, handler.EnqueueRequestsFromMapFunc(r.compatibleCompVersion)).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req

// SetupWithManager sets up the controller with the Manager.
func (r *ConfigConstraintReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&appsv1beta1.ConfigConstraint{}).
// for other resource
Owns(&corev1.ConfigMap{}). // TODO(leon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (r *ConfigurationReconciler) runTasks(taskCtx TaskContext, tasks []Task) (e

// SetupWithManager sets up the controller with the Manager.
func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager, multiClusterMgr multicluster.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&appsv1alpha1.Configuration{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: int(math.Ceil(viper.GetFloat64(constant.CfgKBReconcileWorkers) / 2)),
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/configuration/reconfigure_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (r *ReconfigureReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// SetupWithManager sets up the controller with the Manager.
func (r *ReconfigureReconciler) SetupWithManager(mgr ctrl.Manager, multiClusterMgr multicluster.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&corev1.ConfigMap{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: int(math.Ceil(viper.GetFloat64(constant.CfgKBReconcileWorkers) / 4)),
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/servicedescriptor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (r *ServiceDescriptorReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager sets up the controller with the Manager.
func (r *ServiceDescriptorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&appsv1.ServiceDescriptor{}).
Complete(r)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/shardingdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *ShardingDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.R

// SetupWithManager sets up the controller with the Manager.
func (r *ShardingDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&appsv1.ShardingDefinition{}).
Complete(r)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/sidecardefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (r *SidecarDefinitionReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager sets up the controller with the Manager.
func (r *SidecarDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&appsv1.SidecarDefinition{}).
Watches(&appsv1.ComponentDefinition{}, handler.EnqueueRequestsFromMapFunc(r.matchedCompDefinition)).
Complete(r)
Expand Down
41 changes: 40 additions & 1 deletion controllers/apps/transformer_cluster_normalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package apps
import (
"fmt"

"golang.org/x/exp/maps"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (t *clusterNormalizationTransformer) Transform(ctx graph.TransformContext,
// write-back the resolved definitions and service versions to cluster spec.
t.writeBackCompNShardingSpecs(transCtx)

return nil
return t.patchCRDAPIVersionKey(transCtx)
}

func (t *clusterNormalizationTransformer) resolveCompsNShardings(transCtx *clusterTransformContext) ([]*appsv1.ClusterComponentSpec, []*appsv1.ClusterSharding, error) {
Expand Down Expand Up @@ -409,3 +410,41 @@ func (t *clusterNormalizationTransformer) writeBackCompNShardingSpecs(transCtx *
transCtx.Cluster.Spec.Shardings = shardings
}
}

func (t *clusterNormalizationTransformer) patchCRDAPIVersionKey(transCtx *clusterTransformContext) error {
apiVersions := map[string][]string{}

from := func(name string, annotations map[string]string) {
key := annotations[constant.CRDAPIVersionAnnotationKey]
apiVersions[key] = append(apiVersions[key], name)
}

if transCtx.clusterDef != nil {
from(transCtx.clusterDef.Name, transCtx.clusterDef.Annotations)
} else {
for _, compDef := range transCtx.componentDefs {
from(compDef.Name, compDef.Annotations)
}
for _, shardingDef := range transCtx.shardingDefs {
from(shardingDef.Name, shardingDef.Annotations)
}
}

if len(apiVersions) > 1 {
return fmt.Errorf("multiple CRD API versions found: %v", apiVersions)
}

apiVersion := ""
if len(apiVersions) == 1 {
apiVersion = maps.Keys(apiVersions)[0]
if transCtx.Cluster.Annotations == nil {
transCtx.Cluster.Annotations = make(map[string]string)
}
transCtx.Cluster.Annotations[constant.CRDAPIVersionAnnotationKey] = apiVersion
}

if controllerutil.IsSupportedCRDAPIVersion(apiVersion) {
return nil
}
return graph.ErrPrematureStop // un-supported CRD API version, stop the transformation
}
5 changes: 0 additions & 5 deletions controllers/apps/transformer_cluster_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func loadNCheckClusterDefinition(transCtx *clusterTransformContext, cluster *app
return err
}
}

if cd != nil {
if cd.Generation != cd.Status.ObservedGeneration {
return fmt.Errorf("the referenced ClusterDefinition is not up to date: %s", cd.Name)
Expand All @@ -155,10 +154,6 @@ func loadNCheckClusterDefinition(transCtx *clusterTransformContext, cluster *app
return fmt.Errorf("the referenced ClusterDefinition is unavailable: %s", cd.Name)
}
}

if cd == nil {
cd = &appsv1.ClusterDefinition{}
}
transCtx.clusterDef = cd
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/actionset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (r *ActionSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

// SetupWithManager sets up the controller with the Manager.
func (r *ActionSetReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.ActionSet{}).
Complete(r)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr

// SetupWithManager sets up the controller with the Manager.
func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.Backup{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(dptypes.CfgDataProtectionReconcileWorkers),
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/backuppolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *BackupPolicyReconciler) validateBackupPolicy(backupPolicy *dpv1alpha1.B

// SetupWithManager sets up the controller with the Manager.
func (r *BackupPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.BackupPolicy{}).
Complete(r)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (r *BackupPolicyTemplateReconciler) compatibleBackupPolicyTemplate(ctx cont

// SetupWithManager sets up the controller with the Manager.
func (r *BackupPolicyTemplateReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.BackupPolicyTemplate{}).
Watches(&appsv1.ComponentDefinition{}, handler.EnqueueRequestsFromMapFunc(r.compatibleBackupPolicyTemplate)).
Complete(r)
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/backuprepo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ func (r *BackupRepoReconciler) SetupWithManager(mgr ctrl.Manager) error {
}); err != nil {
return err
}
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.BackupRepo{}).
Watches(&dpv1alpha1.StorageProvider{}, handler.EnqueueRequestsFromMapFunc(r.mapProviderToRepos)).
Watches(&dpv1alpha1.Backup{}, handler.EnqueueRequestsFromMapFunc(r.mapBackupToRepo)).
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/backupschedule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *BackupScheduleReconciler) Reconcile(ctx context.Context, req ctrl.Reque

// SetupWithManager sets up the controller with the Manager.
func (r *BackupScheduleReconciler) SetupWithManager(mgr ctrl.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.BackupSchedule{})

// Compatible with kubernetes versions prior to K8s 1.21, only supports batch v1beta1.
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/gc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewGCReconciler(mgr ctrl.Manager) *GCReconciler {
// taken care of. Other events will be filtered to decrease the load on the controller.
func (r *GCReconciler) SetupWithManager(mgr ctrl.Manager) error {
s := dputils.NewPeriodicalEnqueueSource(mgr.GetClient(), &dpv1alpha1.BackupList{}, r.frequency, dputils.PeriodicalEnqueueSourceOption{})
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.Backup{}, builder.WithPredicates(predicate.NewPredicateFuncs(func(client.Object) bool { return false }))).
WatchesRawSource(s, nil).
Complete(r)
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/log_collection_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *LogCollectionReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// SetupWithManager sets up the controller with the Manager.
func (r *LogCollectionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&batchv1.Job{}, builder.WithPredicates(
failedJobUpdatePredicate{
Funcs: predicate.NewPredicateFuncs(func(object client.Object) bool { return false }),
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *RestoreReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// SetupWithManager sets up the controller with the Manager.
func (r *RestoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.Restore{}).
Owns(&batchv1.Job{}).
Watches(&batchv1.Job{}, handler.EnqueueRequestsFromMapFunc(r.parseRestoreJob)).
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/storageprovider_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (r *StorageProviderReconciler) deleteExternalResources(

// SetupWithManager sets up the controller with the Manager.
func (r *StorageProviderReconciler) SetupWithManager(mgr ctrl.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&dpv1alpha1.StorageProvider{})

mapCSIDriverToProvider := handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, object client.Object) []reconcile.Request {
Expand Down
2 changes: 1 addition & 1 deletion controllers/dataprotection/volumepopulator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r *VolumePopulatorReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// SetupWithManager sets up the controller with the Manager.
func (r *VolumePopulatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&corev1.PersistentVolumeClaim{}).
Owns(&batchv1.Job{}).
Complete(r)
Expand Down
3 changes: 2 additions & 1 deletion controllers/experimental/nodecountscaler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
experimental "github.com/apecloud/kubeblocks/apis/experimental/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/controller/kubebuilderx"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
)

// NodeCountScalerReconciler reconciles a NodeCountScaler object
Expand Down Expand Up @@ -69,7 +70,7 @@ func (r *NodeCountScalerReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// SetupWithManager sets up the controller with the Manager.
func (r *NodeCountScalerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&experimental.NodeCountScaler{}).
Watches(&corev1.Node{}, &nodeScalingHandler{r.Client}).
Watches(&appsv1.Cluster{}, &clusterHandler{r.Client}).
Expand Down
2 changes: 1 addition & 1 deletion controllers/extensions/addon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (r *AddonReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl

// SetupWithManager sets up the controller with the Manager.
func (r *AddonReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&extensionsv1alpha1.Addon{}).
Watches(&batchv1.Job{}, handler.EnqueueRequestsFromMapFunc(r.findAddonJobs)).
WithOptions(controller.Options{
Expand Down
2 changes: 1 addition & 1 deletion controllers/k8score/event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (r *EventReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl

// SetupWithManager sets up the controller with the Manager.
func (r *EventReconciler) SetupWithManager(mgr ctrl.Manager, multiClusterMgr multicluster.Manager) error {
b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr).
For(&corev1.Event{})

if multiClusterMgr != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/operations/opsdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *OpsDefinitionReconciler) updateStatusUnavailable(reqCtx intctrlutil.Req

// SetupWithManager sets up the controller with the Manager.
func (r *OpsDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&opsv1alpha1.OpsDefinition{}).
Complete(r)
}
2 changes: 1 addition & 1 deletion controllers/operations/opsrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *OpsRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// SetupWithManager sets up the controller with the Manager.
func (r *OpsRequestReconciler) SetupWithManager(mgr ctrl.Manager) error {
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr).
For(&opsv1alpha1.OpsRequest{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: int(math.Ceil(viper.GetFloat64(constant.CfgKBReconcileWorkers) / 2)),
Expand Down
4 changes: 2 additions & 2 deletions controllers/workloads/instanceset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *InstanceSetReconciler) SetupWithManager(mgr ctrl.Manager, multiClusterM
func (r *InstanceSetReconciler) setupWithManager(mgr ctrl.Manager, ctx *handler.FinderContext) error {
itsFinder := handler.NewLabelFinder(&workloads.InstanceSet{}, instanceset.WorkloadsManagedByLabelKey, workloads.InstanceSetKind, instanceset.WorkloadsInstanceLabelKey)
podHandler := handler.NewBuilder(ctx).AddFinder(itsFinder).Build()
return intctrlutil.NewNamespacedControllerManagedBy(mgr).
return intctrlutil.NewControllerManagedBy(mgr, &workloads.InstanceSet{}).
For(&workloads.InstanceSet{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
Expand All @@ -132,7 +132,7 @@ func (r *InstanceSetReconciler) setupWithMultiClusterManager(mgr ctrl.Manager,
// TODO: modify handler.getObjectFromKey to support running Job in data clusters
jobHandler := handler.NewBuilder(ctx).AddFinder(delegatorFinder).Build()

b := intctrlutil.NewNamespacedControllerManagedBy(mgr).
b := intctrlutil.NewControllerManagedBy(mgr, &workloads.InstanceSet{}).
For(&workloads.InstanceSet{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
Expand Down
1 change: 1 addition & 0 deletions controllers/workloads/instanceset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var _ = Describe("InstanceSet Controller", func() {
}
its := builder.NewInstanceSetBuilder(testCtx.DefaultNamespace, name).
AddMatchLabelsInMap(commonLabels).
AddAnnotations(constant.CRDAPIVersionAnnotationKey, workloads.GroupVersion.String()).
SetTemplate(template).
AddCustomHandler(action).
GetObject()
Expand Down
3 changes: 3 additions & 0 deletions pkg/constant/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ package constant

// annotations defined by KubeBlocks
const (
// CRDAPIVersionAnnotationKey indicates the CRD API version of the object.
CRDAPIVersionAnnotationKey = "kubeblocks.io/crd-api-version"

KubeBlocksGenerationKey = "kubeblocks.io/generation"
ClusterSnapshotAnnotationKey = "kubeblocks.io/cluster-snapshot" // ClusterSnapshotAnnotationKey saves the snapshot of cluster.
EncryptedSystemAccountsAnnotationKey = "kubeblocks.io/encrypted-system-accounts" // EncryptedSystemAccountsAnnotationKey saves the encrypted system accounts.
Expand Down
Loading