元数据目录中多值运算符的支持

https://blueprints.launchpad.net/glance/+spec/metadata-multivalue-operators-support

元数据目录提供用户可以固定到资源的数据,例如 flavor 的 extra specs。这些数据被 scheduler 用于选择满足 extra specs 中要求的 host。Nova scheduler 实现了运算符来组合 extra specs 中一个 key 下的多个值:<or><all-in>。不幸的是,目录没有提供哪个运算符适用于给定的属性。

此蓝图旨在解决此问题,通过使用适用于每个属性的运算符来扩展当前的 jsons。

问题描述

Horizon 正在进行工作以提供对 extra specs 中单个 key 的多个值的支持,但是 Glance 目前没有提供关于哪个运算符适用于给定属性的信息。在 compute-host-capabilities.json 中,有一个名为 cpu_info:features 的属性。两种运算符 - <all-in><or> 都可以用于此属性。 还有像 cpu_info:model 这样的属性,其中 <or> 是唯一应该工作的运算符。

提议的变更

为了让最终用户(例如 Horizon)知道可以为给定的属性使用哪个运算符,此蓝图通过在 key 下添加一个名为“operators”的新部分来扩展现有属性(以及对象内的属性)。

当前一个示例属性的结构如下

"cpu_info:features": {
    "title": "Features",
    "description": "Specifies CPU flags/features.",
    "type": "array",
    "items": {
        "type": "string",
        "enum": [
            "aes",
            "vme",
            "de"
        ]
    }
}

扩展后

"cpu_info:features": {
    "title": "Features",
    "description": "Specifies CPU flags/features.",
    "operators": [
        "<or>",
        "<all-in>"
    ],
    "type": "array",
    "items": {
        "type": "string",
        "enum": [
            "aes",
            "vme",
            "de"
        ]
    }
}

添加的部分是

"operators": [
    "<or>",
    "<all-in>"
]

此部分是可选的,例如,integer 类型的属性不需要运算符。

此外,glance 不会对“operators”字段进行任何检查。API 消费者需要注意提供有效的运算符给 nova scheduler。目前有三种运算符对 nova scheduler 有效,并且可以与元数据定义一起使用:<or><in><all-in>

备选方案

数据模型影响

这不会影响数据模型,因为“operators”将是存储在数据库表中 json_schema 列中的 blob 的一部分。

REST API 影响

扩展后的 GET 对象体示例

{
    "objects": [
        {
            "name": "object1",
            "namespace": "my-namespace",
            "description": "my-description",
            "properties": {
                "prop1": {
                    "title": "My Property",
                    "description": "More info here",
                    "operators": ["<all-in>"],
                    "type": "string",
                    "readonly": true
                }
            }
        }
    ],
    "first": "/v2/metadefs/objects?limit=1",
    "next": "/v2/metadefs/objects?marker=object1&limit=1",
    "schema": "/v2/schema/metadefs/objects"
}

对象上的 POST/PUT 体示例

{
    "name": "StorageQOS",
    "description": "Our available storage QOS.",
    "required": [
        "MyProperty"
    ],
    "properties": {
        "MyProperty": {
            "type": "string",
            "readonly": false,
            "description": "The My Property",
            "operators": ["<or>"],
            "enum": ["type1", "type2"]
        }
    }
}

由于“operators”字段是可选的,API 消费者需要处理默认值,因为它可能缺失。

安全影响

通知影响

其他最终用户影响

性能影响

其他部署者影响

现有 OpenStack 安装中 jsons 或数据库的升级是不需要的。“operators”部分不是必需的,因此安装可以在不升级的情况下继续运行。

即使在最新的内置元数据定义 json 模板中添加了该值,升级过程也不会更新现有的数据库,也存在属性/对象缺少运算符的可能性。部署者需要手动将元数据定义升级到最新的集合。

开发人员影响

实现

负责人

主要负责人

pawel-koniszewski

其他贡献者

评审人员

核心评审人

lzy-dev

工作项

  • 扩展现有的元数据 jsons,添加 operators 部分。

  • 扩展 API json schema,添加新的选项

依赖项

依赖此蓝图的 Horizon 蓝图:https://blueprints.launchpad.net/horizon/+spec/metadata-widget-multivalue-selection

此蓝图依赖的 Nova 蓝图:https://blueprints.launchpad.net/nova/+spec/add-all-in-list-operator-to-extra-spec-ops

测试

将扩展现有的单元测试和功能测试,以确保返回了新的部分并且它是正确的。测试还将确保 operators 部分是可选的。

文档影响

需要记录新的属性。

参考资料