diff --git a/apis/sql/v1beta1/sqlinstance_types.go b/apis/sql/v1beta1/sqlinstance_types.go index 759cdde24f..913fef4db8 100644 --- a/apis/sql/v1beta1/sqlinstance_types.go +++ b/apis/sql/v1beta1/sqlinstance_types.go @@ -595,7 +595,7 @@ type SQLInstanceStatus struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:resource:categories=gcp,shortName=gcpsqlinstance;gcpsqlinstances // +kubebuilder:subresource:status -// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true" +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true";"cnrm.cloud.google.com/tf2crd=true" // +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" // +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" // +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_sqlinstances.sql.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_sqlinstances.sql.cnrm.cloud.google.com.yaml index dbaec446dc..8550d083ac 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_sqlinstances.sql.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_sqlinstances.sql.cnrm.cloud.google.com.yaml @@ -8,6 +8,7 @@ metadata: cnrm.cloud.google.com/managed-by-kcc: "true" cnrm.cloud.google.com/stability-level: stable cnrm.cloud.google.com/system: "true" + cnrm.cloud.google.com/tf2crd: "true" name: sqlinstances.sql.cnrm.cloud.google.com spec: group: sql.cnrm.cloud.google.com diff --git a/pkg/clients/generated/apis/sql/v1beta1/sqlinstance_types.go b/pkg/clients/generated/apis/sql/v1beta1/sqlinstance_types.go index ed236c652d..fed22c7373 100644 --- a/pkg/clients/generated/apis/sql/v1beta1/sqlinstance_types.go +++ b/pkg/clients/generated/apis/sql/v1beta1/sqlinstance_types.go @@ -585,7 +585,7 @@ type SQLInstanceStatus struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:resource:categories=gcp,shortName=gcpsqlinstance;gcpsqlinstances // +kubebuilder:subresource:status -// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true" +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true";"cnrm.cloud.google.com/tf2crd=true" // +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" // +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" // +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" diff --git a/pkg/controller/registration/registration_controller.go b/pkg/controller/registration/registration_controller.go index 9433f40380..aee3aa7c72 100644 --- a/pkg/controller/registration/registration_controller.go +++ b/pkg/controller/registration/registration_controller.go @@ -248,21 +248,12 @@ func registerDefaultController(r *ReconcileRegistration, config *config.Controll // If we have a choice of controllers, construct predicates to choose between them if hasDirectController && (hasTerraformController || hasDCLController) { - reconcileGate := registry.GetReconcileGate(gvk.GroupKind()) - if reconcileGate != nil { + if reconcileGate := registry.GetReconcileGate(gvk.GroupKind()); reconcileGate != nil { // If reconcile gate is enabled for this gvk, generate a controller-runtime predicate that will // run the direct reconciler only when the reconcile gate returns true. useDirectReconcilerPredicate = kccpredicate.NewReconcilePredicate(r.mgr.GetClient(), gvk, reconcileGate) useLegacyPredicate = kccpredicate.NewInverseReconcilePredicate(r.mgr.GetClient(), gvk, reconcileGate) - } - - if !hasTerraformController && !hasDCLController { - // We're always going to use the direct reconciler - useDirectReconcilerPredicate = nil - useLegacyPredicate = nil - } - - if (hasTerraformController || hasDCLController) && useDirectReconcilerPredicate == nil { + } else { logger.Error(fmt.Errorf("no predicate where we have multiple controllers"), "skipping direct controller registration", "group", gvk.Group, "version", gvk.Version, "kind", gvk.Kind) hasDirectController = false } @@ -282,7 +273,6 @@ func registerDefaultController(r *ReconcileRegistration, config *config.Controll return nil, fmt.Errorf("error adding direct controller for %v to a manager: %w", crd.Spec.Names.Kind, err) } } - // register controllers for dcl-based CRDs if hasDCLController { su, err := dclcontroller.Add(r.mgr, crd, r.dclConverter, r.dclConfig, r.smLoader, r.defaulters, r.jitterGenerator, useLegacyPredicate)