Skip to content

Commit

Permalink
Fix GetMachinesForCluster returning duplicate results (kubernetes-sig…
Browse files Browse the repository at this point in the history
…s#816)

Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri authored and k8s-ci-robot committed Mar 12, 2019
1 parent b59602c commit af298a2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,18 @@ func (c *client) GetMachinesForCluster(cluster *clusterv1.Cluster) ([]*clusterv1
return nil, errors.Wrapf(err, "error listing Machines for Cluster %s/%s", cluster.Namespace, cluster.Name)
}
var machines []*clusterv1.Machine
for _, m := range machineslist.Items {

for i := 0; i < len(machineslist.Items); i++ {
m := &machineslist.Items[i]

for _, or := range m.GetOwnerReferences() {
if or.Kind == cluster.Kind && or.Name == cluster.Name {
machines = append(machines, &m)
continue
machines = append(machines, m)
break
}
}
}
for i := 0; i < len(machineslist.Items); i++ {
machines = append(machines, &machineslist.Items[i])
}

return machines, nil
}

Expand Down

0 comments on commit af298a2

Please sign in to comment.