Add status_reason field to bay

This patch add status_reason field to bay and sync the stack_status_reason
with the stack.

Change-Id: Ie3a550c522c76814620ea28edc782e6e39dcb917
Closes-Bug: #1460091
This commit is contained in:
Lan Qi song 2015-05-30 12:09:50 +08:00
parent 2a4bfa21a9
commit 9a373a48eb
7 changed files with 42 additions and 1 deletions

View File

@ -89,6 +89,9 @@ class Bay(base.APIBase):
status = wtypes.text
"""Status of the bay from the heat stack"""
status_reason = wtypes.text
"""Status reason of the bay from the heat stack"""
discovery_url = wtypes.text
"""Url used for bay node discovery"""
@ -135,7 +138,8 @@ class Bay(base.APIBase):
baymodel_id='4a96ac4b-2447-43f1-8ca6-9fd6f36d146d',
node_count=2,
bay_create_timeout=15,
status="CREATED",
status="CREATE_COMPLETE",
status_reason="CREATE completed successfully",
api_address='172.24.4.3',
node_addresses=['172.24.4.4', '172.24.4.5'],
created_at=datetime.datetime.utcnow(),

View File

@ -225,10 +225,12 @@ class HeatPoller(object):
_update_stack_outputs(self.context, stack, self.bay)
self.bay.status = stack.stack_status
self.bay.status_reason = stack.stack_status_reason
self.bay.save()
raise loopingcall.LoopingCallDone()
elif stack.stack_status != self.bay.status:
self.bay.status = stack.stack_status
self.bay.status_reason = stack.stack_status_reason
self.bay.save()
if stack.stack_status == bay_status.CREATE_FAILED:
LOG.error(_LE('Unable to create bay, stack_id: %(stack_id)s, '

View File

@ -0,0 +1,30 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""add_bay_status_reason
Revision ID: 156ceb17fb0a
Revises: 59e7664a8ba1
Create Date: 2015-05-30 11:34:57.847071
"""
# revision identifiers, used by Alembic.
revision = '156ceb17fb0a'
down_revision = '59e7664a8ba1'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('bay',
sa.Column('status_reason', sa.Text, nullable=True))

View File

@ -129,6 +129,7 @@ class Bay(Base):
node_addresses = Column(JSONEncodedList)
node_count = Column(Integer())
status = Column(String(20), nullable=True)
status_reason = Column(Text, nullable=True)
discovery_url = Column(String(255))

View File

@ -53,6 +53,7 @@ class Bay(base.MagnumPersistentObject, base.MagnumObject,
# UPDATE_IN_PROGRESS|UPDATE_FAILED|UPDATED
# DELETE_IN_PROGRESS|DELETE_FAILED|DELETED
'status': fields.StringField(nullable=True),
'status_reason': fields.StringField(nullable=True),
'api_address': fields.StringField(nullable=True),
'node_addresses': fields.ListOfStringsField(nullable=True),
'node_count': fields.IntegerField(nullable=True),

View File

@ -613,10 +613,12 @@ class TestBayConductorWithK8s(base.TestCase):
bay.status = bay_status.CREATE_IN_PROGRESS
mock_heat_stack.stack_status = bay_status.CREATE_FAILED
mock_heat_stack.stack_status_reason = 'Create failed'
self.assertRaises(loopingcall.LoopingCallDone, poller.poll_and_check)
self.assertEqual(bay.save.call_count, 1)
self.assertEqual(bay.status, bay_status.CREATE_FAILED)
self.assertEqual(bay.status_reason, 'Create failed')
self.assertEqual(poller.attempts, 1)
def test_poll_done(self):

View File

@ -62,6 +62,7 @@ def get_test_bay(**kw):
'e74c40e0-d825-11e2-a28f-0800200c9a66'),
'stack_id': kw.get('stack_id', '047c6319-7abd-4bd9-a033-8c6af0173cd0'),
'status': kw.get('status', 'CREATE_IN_PROGRESS'),
'status_reason': kw.get('status_reason', 'Completed successfully'),
'api_address': kw.get('api_address', '172.17.2.3'),
'node_addresses': kw.get('node_addresses', ['172.17.2.4']),
'node_count': kw.get('node_count', 3),