Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Konstantin A
tower
Commits
9ff39ccf
Commit
9ff39ccf
authored
Mar 07, 2018
by
Aleksey Shirokih
Browse files
Remove obsolete services in migrations
parent
972e7b84
Changes
1
Hide whitespace changes
Inline
Side-by-side
tower/migrations/035_remove_instances.py
View file @
9ff39ccf
...
...
@@ -115,6 +115,13 @@ def migrate(migrator):
'pgbouncer'
,
'nsqadmin'
)
obsolete_services
=
(
'notebook'
,
'redis'
,
'pmwriter'
,
'dev'
)
consul_template_depend_srv
=
(
'clickhouse'
,
'nsqd'
,
...
...
@@ -136,6 +143,10 @@ def migrate(migrator):
if
srv
.
service
in
useless_sevices
and
srv
.
n_instances
==
0
:
srv
.
delete_instance
()
continue
# dead service
if
srv
.
service
in
obsolete_services
:
srv
.
delete_instance
()
continue
# some services has no config
if
not
srv
.
config
:
srv
.
config
=
'{}'
...
...
@@ -198,20 +209,27 @@ def migrate(migrator):
srv
.
save
()
# noc service should be enabled if any noc services was enabled
for
n
in
noc_promote_nodes
:
s
=
Service
.
select
().
where
(
Service
.
environment
==
env
.
id
,
Service
.
node
==
n
,
Service
.
service
==
"noc"
)
s
[
0
].
present
=
True
s
[
0
].
save
()
s
=
Service
.
select
().
where
(
Service
.
environment
==
env
.
id
,
Service
.
node
==
n
,
Service
.
service
==
"noc"
)
if
s
:
s
[
0
].
present
=
True
s
[
0
].
save
()
# add ct to nodes required
for
n
in
ct_promote_nodes
:
Service
(
environment
=
env
.
id
,
service
=
"consul-template"
,
pool
=
None
,
node
=
n
.
id
,
present
=
True
,
loglevel
=
"info"
,
config
=
json
.
dumps
({},
sort_keys
=
True
)
).
save
()
s
=
Service
.
select
().
where
(
Service
.
environment
==
env
.
id
,
Service
.
node
==
n
,
Service
.
service
==
"consul-template"
)
if
not
s
:
Service
(
environment
=
env
.
id
,
service
=
"consul-template"
,
pool
=
None
,
node
=
n
.
id
,
present
=
True
,
loglevel
=
"info"
,
config
=
json
.
dumps
({},
sort_keys
=
True
)
).
save
()
migrator
.
drop_column
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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