Skip to content

Commit

Permalink
Merge pull request #1489 from aspandey/backingstore-labels
Browse files Browse the repository at this point in the history
Noobaa/Backingstore : Need facility to change labels
  • Loading branch information
aspandey authored Jan 9, 2025
2 parents 94c0b93 + 6d562a0 commit 15f7a29
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 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,16 @@ 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 +1342,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 15f7a29

Please sign in to comment.