服务创建和销毁版本化通知¶
https://blueprints.launchpad.net/nova/+spec/service-create-destroy-notification
外部系统可以获取基于服务更新信息的版本化通知 [1],但无法获取服务创建和销毁操作的通知。
添加创建和销毁通知,有助于外部系统在无需回调 Nova API 的情况下获取服务的实时状态。
问题描述¶
用例¶
外部通知消费者,例如 Searchlight,希望在服务创建、更新或销毁时获取服务信息。
提议的变更¶
发送 Service.create 和 Service.destroy 以及 Service.save [2] 的通知。
备选方案¶
唯一的替代方案是定期轮询 /v2/{tenant_id}/os-services/ API,但这会导致信息流较慢,并给 Nova API 和数据库服务带来负载。
数据模型影响¶
预计不会更改数据库模式。
为了使外部系统能够查询正确的服务进行更新或销毁,并使数据与新的 os-services API [3] 保持一致,需要在 ServiceStatusPayload 中添加 uuid 字段。
@base.NovaObjectRegistry.register
class ServiceStatusPayload(base.NovaObject):
SCHEMA = {
'id': ('service', 'id'),
'host': ('service', 'host'),
'binary': ('service', 'binary'),
'topic': ('service', 'topic'),
'report_count': ('service', 'report_count'),
'disabled': ('service', 'disabled'),
'disabled_reason': ('service', 'disabled_reason'),
'availability_zone': ('service', 'availability_zone'),
'last_seen_up': ('service', 'last_seen_up'),
'forced_down': ('service', 'forced_down'),
'version': ('service', 'version')
}
# Version 1.0: Initial version
# Version 1.1: Added id field
VERSION = '1.1'
fields = {
'id': fields.UUIDField(),
'host': fields.StringField(nullable=True),
'binary': fields.StringField(nullable=True),
'topic': fields.StringField(nullable=True),
'report_count': fields.IntegerField(),
'disabled': fields.BooleanField(),
'disabled_reason': fields.StringField(nullable=True),
'availability_zone': fields.StringField(nullable=True),
'last_seen_up': fields.DateTimeField(nullable=True),
'forced_down': fields.BooleanField(),
'version': fields.IntegerField(),
}
def __init__(self, service):
super(ServiceStatusPayload, self).__init__()
self.populate_schema(service=service)
REST API 影响¶
无
安全影响¶
无
通知影响¶
将引入新的通知 service.create 和 service.delete,优先级为 INFO,通知的有效载荷将是现有 Service 版本化对象的序列化形式。Service.create 通知将在服务创建后发出(以便可用 ID),并在服务删除后发送 service.delete 通知。
其他最终用户影响¶
无
性能影响¶
无
其他部署者影响¶
无
开发人员影响¶
无
实现¶
负责人¶
- 主要负责人
liyingjun
工作项¶
发送 service.create 和 service.delete 的版本化通知。
依赖项¶
无
测试¶
除了单元测试,还将添加新的功能测试用例来覆盖新的通知
文档影响¶
无
参考资料¶
[1] 版本化通知 https://docs.openstack.org/developer/nova/notifications.html
[2] https://github.com/openstack/nova/blob/stable/ocata/nova/objects/service.py#L312-L320
历史¶
发布名称 |
描述 |
|---|---|
Queens |
引入 |