Skip to content

Commit

Permalink
fix: filter out replicas from nodeToClusters map (#1194)
Browse files Browse the repository at this point in the history
We have found that using HasLabels and MatchingLabels in the same Kubernetes List call leads
to only one of them being applied. See kubernetes-sigs/controller-runtime#2098

This patch fixes one occurrence of this double usage in the operator code, 
avoiding some unneeded reconciliation cycles.

Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com>
  • Loading branch information
jsilvela committed Dec 16, 2022
1 parent 87274a2 commit 2aaa31c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,10 @@ func (r *ClusterReconciler) mapNodeToClusters(ctx context.Context) handler.MapFu
// get all the pods handled by the operator on that node
err := r.List(ctx, &childPods,
client.MatchingFields{".spec.nodeName": node.Name},
client.MatchingLabels{specs.ClusterRoleLabelName: specs.ClusterRoleLabelPrimary},
client.HasLabels{utils.ClusterLabelName},
client.MatchingLabels{
specs.ClusterRoleLabelName: specs.ClusterRoleLabelPrimary,
utils.PodRoleLabelName: string(utils.PodRoleInstance),
},
)
if err != nil {
log.FromContext(ctx).Error(err, "while getting primary instances for node")
Expand Down

0 comments on commit 2aaa31c

Please sign in to comment.