Commit 9ff39ccf authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

Remove obsolete services in migrations

parent 972e7b84
...@@ -115,6 +115,13 @@ def migrate(migrator): ...@@ -115,6 +115,13 @@ def migrate(migrator):
'pgbouncer', 'pgbouncer',
'nsqadmin' 'nsqadmin'
) )
obsolete_services = (
'notebook',
'redis',
'pmwriter',
'dev'
)
consul_template_depend_srv = ( consul_template_depend_srv = (
'clickhouse', 'clickhouse',
'nsqd', 'nsqd',
...@@ -136,6 +143,10 @@ def migrate(migrator): ...@@ -136,6 +143,10 @@ def migrate(migrator):
if srv.service in useless_sevices and srv.n_instances == 0: if srv.service in useless_sevices and srv.n_instances == 0:
srv.delete_instance() srv.delete_instance()
continue continue
# dead service
if srv.service in obsolete_services:
srv.delete_instance()
continue
# some services has no config # some services has no config
if not srv.config: if not srv.config:
srv.config = '{}' srv.config = '{}'
...@@ -198,20 +209,27 @@ def migrate(migrator): ...@@ -198,20 +209,27 @@ def migrate(migrator):
srv.save() srv.save()
# noc service should be enabled if any noc services was enabled # noc service should be enabled if any noc services was enabled
for n in noc_promote_nodes: for n in noc_promote_nodes:
s = Service.select().where(Service.environment == env.id, Service.node == n, Service.service == "noc") s = Service.select().where(Service.environment == env.id,
s[0].present = True Service.node == n,
s[0].save() Service.service == "noc")
if s:
s[0].present = True
s[0].save()
# add ct to nodes required # add ct to nodes required
for n in ct_promote_nodes: for n in ct_promote_nodes:
Service( s = Service.select().where(Service.environment == env.id,
environment=env.id, Service.node == n,
service="consul-template", Service.service == "consul-template")
pool=None, if not s:
node=n.id, Service(
present=True, environment=env.id,
loglevel="info", service="consul-template",
config=json.dumps({}, sort_keys=True) pool=None,
).save() node=n.id,
present=True,
loglevel="info",
config=json.dumps({}, sort_keys=True)
).save()
migrator.drop_column( migrator.drop_column(
......
Supports Markdown
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