Commit 9b177d15 authored by Stan Hu's avatar Stan Hu

Merge branch 'refactor_ee_cluster_deployment_platform' into 'master'

Refactor EE find_group_cluster_platform_kubernetes

See merge request gitlab-org/gitlab-ee!14422
parents 52b02dcb 57f1b976
......@@ -17,13 +17,14 @@ module EE
def find_group_cluster_platform_kubernetes(environment: nil)
return super unless environment && feature_available?(:multiple_clusters)
# on_environment use CASE which returns numbers in descending order
# So we have to use `hierarchy_order: :desc` + last
# With relevant_only: true
# on_environment use CASE which returns numbers in ascending order
# So we can use `hierarchy_order: :asc` + first
::Clusters::Cluster
.enabled
.on_environment(environment)
.ancestor_clusters_for_clusterable(self, hierarchy_order: :desc)
.last&.platform_kubernetes
.on_environment(environment, relevant_only: true)
.ancestor_clusters_for_clusterable(self, hierarchy_order: :asc)
.first&.platform_kubernetes
end
override :find_instance_cluster_platform_kubernetes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment