From 4a29b59aff880adfa324a49d732b2f35f8f69043 Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Mon, 9 Dec 2024 14:59:48 +0530 Subject: [PATCH] Noobaa/Backingstore : Need facility to change labels We need to allow to modify the matchLabel of topologySpreadConstraints for noobaa's backingstore pods. https://issues.redhat.com/browse/DFBUGS-277 Signed-off-by: Ashish Pandey --- pkg/backingstore/reconciler.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/backingstore/reconciler.go b/pkg/backingstore/reconciler.go index 19499c86f..a65dca10e 100644 --- a/pkg/backingstore/reconciler.go +++ b/pkg/backingstore/reconciler.go @@ -1169,6 +1169,13 @@ func (r *Reconciler) needUpdate(pod *corev1.Pod) bool { } } + var pod_label = pod.Labels["backingstore"] + var bs_label = r.BackingStore.Labels["backingstore"] + if (bs_label != "") && (pod_label != bs_label) { + r.Logger.Warnf("Backingstore lable has been modified to (%v) and it is different from pod lable: (%v)", bs_label, pod_label) + return true + } + for _, name := range []string{"NOOBAA_LOG_LEVEL", "NOOBAA_LOG_COLOR"} { configMapValue := r.CoreAppConfig.Data[name] noobaaLogEnvVar := util.GetEnvVariable(&c.Env, name) @@ -1305,10 +1312,15 @@ func (r *Reconciler) updatePodTemplate() error { r.PodAgentTemplate.Spec.ImagePullSecrets = []corev1.LocalObjectReference{*r.NooBaa.Spec.ImagePullSecret} } + + bs_label, ok := r.BackingStore.Labels["backingstore"] + if !ok || bs_label == "" { + bs_label = "noobaa" + } r.PodAgentTemplate.Labels = map[string]string{ "app": "noobaa", "pool": r.BackingStore.Name, - "backingstore": "noobaa", + "backingstore": bs_label, } if r.NooBaa.Spec.Tolerations != nil { r.PodAgentTemplate.Spec.Tolerations = r.NooBaa.Spec.Tolerations @@ -1329,7 +1341,7 @@ func (r *Reconciler) updatePodTemplate() error { NodeTaintsPolicy: &honor, LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - "backingstore": "noobaa", + "backingstore": bs_label, }, }, }