From ce40a6b055ce3e08d9b9b082774cf404517e473e Mon Sep 17 00:00:00 2001 From: Abirdcfly Date: Thu, 2 Nov 2023 11:20:18 +0800 Subject: [PATCH] feat: add componentplan-release label to subscription Signed-off-by: Abirdcfly --- config/manager/manager.yaml | 2 +- controllers/subscription_controller.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 3c6063ee..3733167f 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -70,7 +70,7 @@ spec: resources: limits: cpu: 5000m - memory: 1536Mi + memory: 15360Mi requests: cpu: 10m memory: 64Mi diff --git a/controllers/subscription_controller.go b/controllers/subscription_controller.go index 2ef9ce81..31ea9d60 100644 --- a/controllers/subscription_controller.go +++ b/controllers/subscription_controller.go @@ -88,7 +88,17 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request return reconcile.Result{}, utils.IgnoreNotFound(err) } logger.V(1).Info("Get Subscription instance") - + if sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] != sub.Spec.Name { + if sub.GetLabels() == nil { + sub.Labels = make(map[string]string) + } + sub.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] = sub.Spec.Name + err = r.Update(ctx, sub) + if err != nil { + logger.Error(err, "Failed to update Subscription release label") + } + return ctrl.Result{}, err + } // Get watched component component := &corev1alpha1.Component{} err = r.Get(ctx, types.NamespacedName{Namespace: sub.Spec.ComponentRef.Namespace, Name: sub.Spec.ComponentRef.Name}, component)