@@ -42,20 +40,30 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
...
@@ -42,20 +40,30 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
belongs_to:project,class_name: 'Project'
belongs_to:project,class_name: 'Project'
# 10.1 ~ 10.2
# When users create a cluster, KubernetesService is automatically synchronized
# When users create a cluster, KubernetesService is automatically synchronized
# with Platforms::Kubernetes due to delegate Kubernetes specific logic.
# with Platforms::Kubernetes due to delegate Kubernetes specific logic.
# We only target unmanaged KubernetesService records.
# We only target unmanaged KubernetesService records.
#
# 10.3
# We no longer create KubernetesService because Platforms::Kubernetes has the specific logic.
#
# "unmanaged" means "unmanaged by Platforms::Kubernetes(New archetecture)"
#
# "cluster_projects.project_id IS NULL" -> it's not copied from KubernetesService
# "services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')" -> KubernetesService has unique configuration which is not included in Platforms::Kubernetes
scope:unmanaged_kubernetes_service,->do
scope:unmanaged_kubernetes_service,->do
joins('INNER JOIN projects ON projects.id = services.project_id '\
joins('INNER JOIN projects ON projects.id = services.project_id')
'INNER JOIN cluster_projects ON projects.id = cluster_projects.project_id '\
.where("services.category = 'deployment'")
'INNER JOIN clusters ON cluster_projects.cluster_id = clusters.id '\
.where("services.type = 'KubernetesService'")
'INNER JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = clusters.id')
.where("services.template = FALSE")
.where("services.category = 'deployment' AND services.type = 'KubernetesService' "\
.where("NOT EXISTS (?)",
"AND ( "\
PlatformsKubernetes
" cluster_projects.project_id IS NULL "\
.joins('INNER JOIN cluster_projects ON cluster_projects.project_id = projects.id')