fix node-delete issues and make status changes to cluster if node in error

This commit is contained in:
QI ZHANG 2015-03-05 16:12:39 +08:00
parent 249e4675de
commit 839a6e8e98
5 changed files with 21 additions and 7 deletions

View File

@ -34,6 +34,7 @@ pip install -r requirements.txt
```
* Create keystone service for senlin
There is a setup-service script under tools folder to do this for you, you should use the script to automate this step and step 5 for you.
```
@ -41,6 +42,7 @@ keystone service-create --type clustering --name senlin
```
* Create keystone endpoint for senlin
There is a setup-service script under tools folder to do this for you, you should use the script to automate step 4 and this step for you.
@ -49,6 +51,7 @@ keystone endpoint-create --region RegionOne --service <service_id> --publicurl '
```
* Update configuration file /etc/senlin/senlin.conf according to your system
Note that the item policy_dir should be pointed to a folder which include file policy.json
* Start senlin engine and api service

View File

@ -272,6 +272,7 @@ class Event(BASE, SenlinBase, SoftDelete):
cluster_id = sqlalchemy.Column(sqlalchemy.String(36),
sqlalchemy.ForeignKey('cluster.id'),
nullable=True)
cluster = relationship(Cluster, backref=backref('events'))
level = sqlalchemy.Column(sqlalchemy.String(64))
user = sqlalchemy.Column(sqlalchemy.String(36))
project = sqlalchemy.Column(sqlalchemy.String(36))

View File

@ -38,11 +38,11 @@ class Cluster(periodic_task.PeriodicTasks):
'''
STATUSES = (
INIT, CREATING, ACTIVE, ERROR, DELETING, DELETED,
INIT, CREATING, ACTIVE, ERROR, CRITICAL, DELETING, DELETED, WARNING,
UPDATING, UPDATE_CANCELLED,
) = (
'INIT', 'CREATING', 'ACTIVE', 'ERROR', 'DELETING', 'DELETED',
'UPDATING', 'UPDATE_CANCELLED',
'INIT', 'CREATING', 'ACTIVE', 'ERROR', 'CRITICAL', 'DELETING', 'DELETED',
'WARNING', 'UPDATING', 'UPDATE_CANCELLED',
)
def __init__(self, name, profile_id, size=0, context=None, **kwargs):

View File

@ -33,10 +33,10 @@ class Node(object):
'''
statuses = (
INIT, ACTIVE, ERROR, DELETED,
INIT, ACTIVE, ERROR, DELETED, WARNING,
CREATING, UPDATING, DELETING,
) = (
'INIT', 'ACTIVE', 'ERROR', 'DELETED',
'INIT', 'ACTIVE', 'ERROR', 'DELETED', 'WARNING',
'CREATING', 'UPDATING', 'DELETING',
)
@ -207,7 +207,17 @@ class Node(object):
if reason:
values['status_reason'] = reason
db_api.node_update(context, self.id, values)
# TODO(anyone): generate event record
# Update cluster status
if self.cluster_id:
values = {}
if status == self.ERROR:
values['status'] = self.WARNING
else:
values['status'] = self.ACTIVE
if reason:
values['status_reason'] = "Node %s: %s" % (self.id, reason)
db_api.cluster_update(context, self.cluster_id, values)
# TODO(anyone): generate event record
def do_create(self, context):
if self.status != self.INIT:

View File

@ -747,7 +747,7 @@ class EngineService(service.Service):
# Create a node instance
tags = tags or {}
node = node_mod.Node(name, db_profile.id, cluster_id, role=role,
node = node_mod.Node(name, db_profile.id, cluster_id, context, role=role,
tags=tags)
node.store(context)