ancestor_clusters_for_clusterable should return Relation, not Array

Note: This was introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22308.

The following discussion from gitlab-ce!22996 should be addressed:

  • @ayufan started a discussion: (+4 comments)

    Do we return an array of clusters?

    Can we do AR relation?

We use ancestor_clusters_for_clusterable so that we can return a list of clusters in order of hierarchy.

I would actually like to return AR for ancestor_clusters_for_clusterable but have not found a way. See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22308#note_121372981 for gory details.

This also have the downstream impact of us having to use Kaminari.paginate_array(clusters) in ClustersController.

Proposal

We need a way to return the list of clusters ordered by hierarchy but returning a Relation. Let's use ClustersHierarchy which was introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30063

Replace Kaminari.paginate_array(clusters) in ClustersController with normal Kaminari pagination 🎉

Edited by 🤖 GitLab Bot 🤖