Skip to content

Commit 4d21a20

Browse files
committed
Fix node spec podLabels bug
The operator does not add node spec's podLabels to the statefulsets unless a user also defines podLabels for the cluster spec. This change will always add both cluster and node spec podLabels as long as they are defined. If same labels are defined for both cluster spec and pod spec then it'll prefer node spec values over cluster spec.
1 parent e5f726e commit 4d21a20

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

controllers/druid/handler.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,17 +1268,16 @@ func makeLabelsForDruid(druid *v1alpha1.Druid) map[string]string {
12681268
}
12691269

12701270
// makeLabelsForDruid returns the labels for selecting the resources
1271-
// belonging to the given druid CR name.
1271+
// belonging to the given druid CR name. adds labels from both node &
1272+
// cluster specs. node spec labels will take precedence over clusters labels
12721273
func makeLabelsForNodeSpec(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, clusterName, nodeSpecUniqueStr string) map[string]string {
12731274
var labels = map[string]string{}
12741275

1275-
// if both labels are present at both cluster and node spec
1276-
// labels should be merged.
1277-
if nodeSpec.PodLabels != nil && m.Spec.PodLabels != nil {
1278-
labels = nodeSpec.PodLabels
1276+
for k, v := range m.Spec.PodLabels {
1277+
labels[k] = v
12791278
}
12801279

1281-
for k, v := range m.Spec.PodLabels {
1280+
for k, v := range nodeSpec.PodLabels {
12821281
labels[k] = v
12831282
}
12841283

0 commit comments

Comments
 (0)