Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
8bc3221f
Commit
8bc3221f
authored
Jan 05, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix query to look for proper unmanaged kubernetes service
parent
acfb8464
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
...grate_kubernetes_service_to_new_clusters_architectures.rb
+12
-17
No files found.
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
View file @
8bc3221f
...
...
@@ -55,24 +55,16 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
belongs_to
:project
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Project'
scope
:unmanaged_kubernetes_service
,
->
do
where
(
category:
'deployment'
)
joins
(
'LEFT JOIN projects ON projects.id = services.project_id'
)
.
joins
(
'LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id'
)
.
joins
(
'LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id'
)
.
where
(
category:
'deployment'
)
.
where
(
type:
'KubernetesService'
)
.
where
(
template:
false
)
.
where
(
"NOT EXISTS (?)"
,
MigrateKubernetesServiceToNewClustersArchitectures
::
PlatformsKubernetes
.
joins
(
'INNER JOIN projects ON projects.id = services.project_id'
)
.
joins
(
'INNER JOIN cluster_projects ON cluster_projects.project_id = projects.id'
)
.
where
(
'cluster_projects.cluster_id = cluster_platforms_kubernetes.cluster_id'
)
.
where
(
"services.properties LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')"
)
.
select
(
'1'
)
)
.
order
(
project_id: :asc
)
end
scope
:kubernetes_service_without_template
,
->
do
where
(
category:
'deployment'
)
.
where
(
type:
'KubernetesService'
)
.
where
(
template:
false
)
.
order
(
project_id: :asc
)
.
where
(
"services.properties LIKE '%api_url%'"
)
.
where
(
"(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL"
)
.
group
(
:id
)
.
order
(
id: :asc
)
end
end
...
...
@@ -148,7 +140,10 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
Gitlab
::
Database
.
bulk_insert
(
'cluster_projects'
,
rows_for_cluster_projects
)
end
MigrateKubernetesServiceToNewClustersArchitectures
::
Service
.
kubernetes_service_without_template
.
update_all
(
active:
false
)
connection
.
execute
<<~
SQL
UPDATE services SET active = false
WHERE category = 'deployment' AND type = 'KubernetesService' AND template = false
SQL
end
def
down
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment