Skip to content

Commit

Permalink
Fixed an issue where the provider templates depend on the management …
Browse files Browse the repository at this point in the history
…object and the management object depends on the provider templates making it impossible to deploy kcm with the create management flag set to false. Resolves issue k0rdent#940
  • Loading branch information
kylewuolle committed Feb 3, 2025
1 parent 354c017 commit 4a401cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
5 changes: 3 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ func main() {
currentNamespace := utils.CurrentNamespace()

templateReconciler := controller.TemplateReconciler{
Client: mgr.GetClient(),
SystemNamespace: currentNamespace,
Client: mgr.GetClient(),
CreateManagement: createManagement,
SystemNamespace: currentNamespace,
DefaultRegistryConfig: helm.DefaultRegistryConfig{
URL: defaultRegistryURL,
RepoType: determinedRepositoryType,
Expand Down
5 changes: 1 addition & 4 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,7 @@ func (r *ReleaseReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
//
if !r.CreateManagement {
return nil
}

// There's no Release objects created yet and we need to trigger reconcile
initChannel := make(chan event.GenericEvent, 1)
initChannel <- event.GenericEvent{Object: &kcm.Release{}}
Expand Down
17 changes: 3 additions & 14 deletions internal/controller/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type TemplateReconciler struct {

SystemNamespace string
DefaultRegistryConfig helm.DefaultRegistryConfig
CreateManagement bool
}

type ClusterTemplateReconciler struct {
Expand Down Expand Up @@ -82,10 +83,6 @@ func (r *ClusterTemplateReconciler) Reconcile(ctx context.Context, req ctrl.Requ

management, err := r.getManagement(ctx, clusterTemplate)
if err != nil {
if apierrors.IsNotFound(err) {
l.Info("Management is not created yet, retrying")
return ctrl.Result{RequeueAfter: defaultRequeueTime}, nil
}
return ctrl.Result{}, err
}
if !management.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -136,10 +133,6 @@ func (r *ServiceTemplateReconciler) Reconcile(ctx context.Context, req ctrl.Requ

management, err := r.getManagement(ctx, serviceTemplate)
if err != nil {
if apierrors.IsNotFound(err) {
l.Info("Management is not created yet, retrying")
return ctrl.Result{RequeueAfter: defaultRequeueTime}, nil
}
return ctrl.Result{}, err
}
if !management.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -173,14 +166,10 @@ func (r *ProviderTemplateReconciler) Reconcile(ctx context.Context, req ctrl.Req
}

management, err := r.getManagement(ctx, providerTemplate)
if err != nil {
if apierrors.IsNotFound(err) {
l.Info("Management is not created yet, retrying")
return ctrl.Result{RequeueAfter: defaultRequeueTime}, nil
}
if r.CreateManagement && err != nil {
return ctrl.Result{}, err
}
if !management.DeletionTimestamp.IsZero() {
if management != nil && !management.DeletionTimestamp.IsZero() {
l.Info("Management is being deleted, skipping ProviderTemplate reconciliation")
return ctrl.Result{}, nil
}
Expand Down

0 comments on commit 4a401cf

Please sign in to comment.