Add namespace filter to Client.List
Without the namespace filter Client.List can get resources across
namespaces. If two clusters are created in different namespaces with the
same cluster name the Client.List will grab both of them and the second
cluster won't come up.
@@ -229,9 +229,11 @@ func (r *Reconciler) reconcilePatroniStatus(
instances := &appsv1.StatefulSetList{}
if err == nil {
- err = r.Client.List(ctx, instances, &client.ListOptions{
- LabelSelector: instanceSelector,
- })
+ err = errors.WithStack(
+ r.Client.List(ctx, instances,
+ client.InNamespace(cluster.Namespace),
+ client.MatchingLabelsSelector{Selector: instanceSelector},
+ ))
}
if err == nil {
