Skip to content

Commit

Permalink
Merge pull request #99 from Mirantis/fix-templates-reconciling
Browse files Browse the repository at this point in the history
Fix OwnerReference configuration for HelmRelease
  • Loading branch information
eromanova authored Jul 17, 2024
2 parents 9a0831e + 51ce25a commit 3155ed1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/controller/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (r *DeploymentReconciler) Update(ctx context.Context, l logr.Logger, deploy
})

if !deployment.Spec.DryRun {
ownerRef := metav1.OwnerReference{
ownerRef := &metav1.OwnerReference{
APIVersion: hmc.GroupVersion.String(),
Kind: hmc.DeploymentKind,
Name: deployment.Name,
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/management_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *ManagementReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, r.Client.Update(ctx, management)
}

ownerRef := metav1.OwnerReference{
ownerRef := &metav1.OwnerReference{
APIVersion: hmc.GroupVersion.String(),
Kind: hmc.ManagementKind,
Name: management.Name,
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (p *Poller) reconcileHMCTemplates(ctx context.Context) error {
Name: helmChart.Name,
Namespace: helmChart.Namespace,
}
_, operation, err = helm.ReconcileHelmRelease(ctx, p.Client, hmcTemplatesReleaseName, hmc.TemplatesNamespace, nil, metav1.OwnerReference{}, chartRef, defaultReconcileInterval, nil)
_, operation, err = helm.ReconcileHelmRelease(ctx, p.Client, hmcTemplatesReleaseName, hmc.TemplatesNamespace, nil, nil, chartRef, defaultReconcileInterval, nil)
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions internal/helm/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ReconcileHelmRelease(
name string,
namespace string,
values *apiextensionsv1.JSON,
ownerReference metav1.OwnerReference,
ownerReference *metav1.OwnerReference,
chartRef *hcv2.CrossNamespaceSourceReference,
reconcileInterval time.Duration,
dependsOn []meta.NamespacedObjectReference,
Expand All @@ -51,7 +51,9 @@ func ReconcileHelmRelease(
helmRelease.Labels = make(map[string]string)
}
helmRelease.Labels[hmc.HMCManagedLabelKey] = "true"
helmRelease.OwnerReferences = []metav1.OwnerReference{ownerReference}
if ownerReference != nil {
helmRelease.OwnerReferences = []metav1.OwnerReference{*ownerReference}
}
helmRelease.Spec = hcv2.HelmReleaseSpec{
ChartRef: chartRef,
Interval: metav1.Duration{Duration: reconcileInterval},
Expand Down

0 comments on commit 3155ed1

Please sign in to comment.