Skip to content

Commit

Permalink
Noobaa/Backingstore : Need facility to change labels
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aspandey committed Jan 9, 2025
1 parent af3ce52 commit 4a29b59
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/backingstore/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -1329,7 +1341,7 @@ func (r *Reconciler) updatePodTemplate() error {
NodeTaintsPolicy: &honor,
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"backingstore": "noobaa",
"backingstore": bs_label,
},
},
}
Expand Down

0 comments on commit 4a29b59

Please sign in to comment.