Skip to content

Commit

Permalink
Corrected Logstash label logstash.k8s.elastic.co/statefulset-name to …
Browse files Browse the repository at this point in the history
…include the -ls suffix, fixing issues preventing pod recreation during ECK upgrade from version 2.11 to 2.12. (elastic#7788) (elastic#7812)

Fixes: elastic#7742
(cherry picked from commit 09e75f8)

Co-authored-by: kaisecheng <69120390+kaisecheng@users.noreply.github.com>
  • Loading branch information
kvalliyurnatt and kaisecheng authored May 14, 2024
1 parent 9dd6dfc commit 6404bcb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/logstash/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ func ensureSTSNameLabelIsSetOnPods(params Params) error {
if err != nil {
return err
}
if _, ok := sts.Spec.Template.Labels[labels.StatefulSetNameLabelName]; ok {
if val, ok := sts.Spec.Template.Labels[labels.StatefulSetNameLabelName]; ok && (val == logstashv1alpha1.Name(params.Logstash.Name)) {
// label is already in place, great
return nil
}
// add the missing label and update the sts resource
if sts.Spec.Template.Labels == nil {
sts.Spec.Template.Labels = map[string]string{}
}
sts.Spec.Template.Labels[labels.StatefulSetNameLabelName] = params.Logstash.Name
sts.Spec.Template.Labels[labels.StatefulSetNameLabelName] = logstashv1alpha1.Name(params.Logstash.Name)
return params.Client.Update(params.Context, &sts)
}

0 comments on commit 6404bcb

Please sign in to comment.