Skip to content

chore: refactor parameters partV: decouple apps dependence on parameters and tidy up #8620

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

Merged
merged 9 commits into from
Feb 27, 2025
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
10 changes: 8 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import (

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
appsv1beta1 "github.com/apecloud/kubeblocks/apis/apps/v1beta1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
experimentalv1alpha1 "github.com/apecloud/kubeblocks/apis/experimental/v1alpha1"
extensionsv1alpha1 "github.com/apecloud/kubeblocks/apis/extensions/v1alpha1"
Expand Down Expand Up @@ -114,7 +113,6 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(appsv1alpha1.AddToScheme(scheme))
utilruntime.Must(appsv1beta1.AddToScheme(scheme))
utilruntime.Must(appsv1.AddToScheme(scheme))
utilruntime.Must(opsv1alpha1.AddToScheme(scheme))
utilruntime.Must(dpv1alpha1.AddToScheme(scheme))
Expand Down Expand Up @@ -606,6 +604,14 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Parameter")
os.Exit(1)
}
if err = (&parameterscontrollers.ComponentDrivenParameterReconciler{
Client: client,
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("component-driven-parameter-controller"),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ComponentParameter")
os.Exit(1)
}
if err = (&parameterscontrollers.ComponentParameterReconciler{
Client: client,
Scheme: mgr.GetScheme(),
Expand Down
1 change: 0 additions & 1 deletion controllers/apps/clusterdefinition_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ var _ = Describe("ClusterDefinition Controller", func() {
testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ClusterDefinitionSignature, true, ml)
testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ShardingDefinitionSignature, true, ml)
testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ComponentDefinitionSignature, true, ml)
testapps.ClearResources(&testCtx, intctrlutil.ConfigConstraintSignature, ml)

// namespaced
testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ConfigMapSignature, true, inNS, ml)
Expand Down
26 changes: 3 additions & 23 deletions controllers/apps/component/component_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1"
appsutil "github.com/apecloud/kubeblocks/controllers/apps/util"
Expand Down Expand Up @@ -156,16 +155,14 @@ func (r *ComponentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
&componentAccountTransformer{},
// handle the TLS configuration
&componentTLSTransformer{},
// rerender parameters after v-scale and h-scale
&componentRelatedParametersTransformer{Client: r.Client},
// resolve and build vars for template and Env
&componentVarsTransformer{},
// provision component system accounts, depend on vars
&componentAccountProvisionTransformer{},
// render config/script templates
&componentFileTemplateTransformer{},
// render component configurations
&componentConfigurationTransformer{Client: r.Client},
&componentReloadActionSidecarTransformer{Client: r.Client},
// handle restore before workloads transform
&componentRestoreTransformer{Client: r.Client},
// handle the component workload
Expand Down Expand Up @@ -217,8 +214,7 @@ func (r *ComponentReconciler) setupWithManager(mgr ctrl.Manager) error {
Owns(&corev1.Secret{}).
Owns(&corev1.ConfigMap{}).
Watches(&dpv1alpha1.Restore{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources)).
Watches(&corev1.PersistentVolumeClaim{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources)).
Watches(&appsv1alpha1.Configuration{}, handler.EnqueueRequestsFromMapFunc(r.configurationEventHandler))
Watches(&corev1.PersistentVolumeClaim{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources))

if viper.GetBool(constant.EnableRBACManager) {
b.Owns(&rbacv1.RoleBinding{}).
Expand All @@ -236,8 +232,7 @@ func (r *ComponentReconciler) setupWithMultiClusterManager(mgr ctrl.Manager, mul
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
}).
Owns(&workloads.InstanceSet{}).
Watches(&dpv1alpha1.Restore{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources)).
Watches(&appsv1alpha1.Configuration{}, handler.EnqueueRequestsFromMapFunc(r.configurationEventHandler))
Watches(&dpv1alpha1.Restore{}, handler.EnqueueRequestsFromMapFunc(r.filterComponentResources))

eventHandler := handler.EnqueueRequestsFromMapFunc(r.filterComponentResources)
multiClusterMgr.Watch(b, &corev1.Service{}, eventHandler).
Expand Down Expand Up @@ -271,18 +266,3 @@ func (r *ComponentReconciler) filterComponentResources(ctx context.Context, obj
},
}
}

func (r *ComponentReconciler) configurationEventHandler(_ context.Context, obj client.Object) []reconcile.Request {
cr, ok := obj.(*appsv1alpha1.Configuration)
if !ok {
return []reconcile.Request{}
}
return []reconcile.Request{
{
NamespacedName: types.NamespacedName{
Namespace: obj.GetNamespace(),
Name: constant.GenerateClusterComponentName(cr.Spec.ClusterRef, cr.Spec.ComponentName),
},
},
}
}
2 changes: 0 additions & 2 deletions controllers/apps/component/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
appsv1beta1 "github.com/apecloud/kubeblocks/apis/apps/v1beta1"
dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1"
"github.com/apecloud/kubeblocks/pkg/controller/model"
Expand All @@ -34,7 +33,6 @@ import (
func init() {
model.AddScheme(clientgoscheme.AddToScheme)
model.AddScheme(appsv1alpha1.AddToScheme)
model.AddScheme(appsv1beta1.AddToScheme)
model.AddScheme(appsv1.AddToScheme)
model.AddScheme(dpv1alpha1.AddToScheme)
model.AddScheme(snapshotv1.AddToScheme)
Expand Down
103 changes: 0 additions & 103 deletions controllers/apps/component/transformer_component_configuration.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
parametersv1alpha1 "github.com/apecloud/kubeblocks/apis/parameters/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1"
appsutil "github.com/apecloud/kubeblocks/controllers/apps/util"
"github.com/apecloud/kubeblocks/pkg/constant"
Expand Down Expand Up @@ -256,7 +256,7 @@ func compOwnedKinds() []client.ObjectList {
&corev1.SecretList{},
&corev1.ConfigMapList{},
&corev1.PersistentVolumeClaimList{},
&appsv1alpha1.ConfigurationList{},
&parametersv1alpha1.ComponentParameterList{},
&corev1.ServiceAccountList{},
&rbacv1.RoleList{},
&rbacv1.RoleBindingList{},
Expand Down
62 changes: 0 additions & 62 deletions controllers/apps/component/transformer_component_parameters.go

This file was deleted.

Loading