首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >支持windows虚拟机和linux虚拟机分区调度

支持windows虚拟机和linux虚拟机分区调度

作者头像
后端云
发布2018-10-24 10:48:32
3.1K0
发布2018-10-24 10:48:32
举报
文章被收录于专栏:后端云后端云

有一个新装的环境测试报windows,linux分区调度不支持

测试前提条件:

  • Openstack Pike
  • image文件配置了metadata。openstack image set –property os_type=windows image_id
  • 主机组也配置了metadate。nova aggregate-set-metadata aggregate_id os_type=windows

用该image生成的vm,没有被nova-scheduler调度到windows主机组。

分析原因,首先想到的是nova的配置文件filter选项有没有配置对应的filter。

# vim /etc/nova/nova.conf

scheduler_default_filters果然没有配置AggregateImagePropertiesIsolation

AggregateImagePropertiesIsolation的作用:Checks a host in an aggregate that metadata key/value match with image properties.

将AggregateImagePropertiesIsolation加上,重启openstack-nova-scheduler.service但生成的vm仍旧不能被调度到windows主机组。

查看日志文件/var/log/nova/nova-scheduler.log:发现有这句话:Filter AggregateImagePropertiesIsolation returned 5 host(s) get_filtered_objects /usr/lib/python2.7/site-packages/nova/filters.py:104

说明filter:AggregateImagePropertiesIsolation生效了,但是却不能识别出windows主机组,返回了5 host(s),该环境一共就5个计算节点。

查看代码逻辑:

# vim /lib/python2.7/site-packages/nova/scheduler/filters/aggregate_image_properties_isolation.py
class AggregateImagePropertiesIsolation(filters.BaseHostFilter):
    """AggregateImagePropertiesIsolation works with image properties."""

    # Aggregate data and instance type does not change within a request
    run_filter_once_per_request = True

    def host_passes(self, host_state, spec_obj):
        """Checks a host in an aggregate that metadata key/value match        with image properties.        """
        cfg_namespace = (CONF.filter_scheduler.
            aggregate_image_properties_isolation_namespace)
        cfg_separator = (CONF.filter_scheduler.
            aggregate_image_properties_isolation_separator)

        image_props = spec_obj.image.properties if spec_obj.image else {}
        LOG.debug("##### image_props: %s #####" % image_props)
        metadata = utils.aggregate_metadata_get_by_host(host_state)

        for key, options in metadata.items():
            if (cfg_namespace and
                    not key.startswith(cfg_namespace + cfg_separator)):
                continue
            prop = None
            try:
                prop = image_props.get(key)
            except AttributeError:
                LOG.warning(_LW("Host '%(host)s' has a metadata key '%(key)s' "
                                "that is not present in the image metadata."),
                            {"host": host_state.host, "key": key})
                continue

            # NOTE(sbauza): Aggregate metadata is only strings, we need to
            # stringify the property to match with the option
            # TODO(sbauza): Fix that very ugly pattern matching
            if prop and str(prop) not in options:
                LOG.debug("%(host_state)s fails image aggregate properties "
                            "requirements. Property %(prop)s does not "
                            "match %(options)s.",
                          {'host_state': host_state,
                           'prop': prop,
                           'options': options})
                return False
        return True

通过代码得知,只有一种情况下才会返回False,其他情况都是返回True。False就是计算节点被过滤掉,True是没被过滤掉。现在的实际情况是没有被过滤,全部计算节点返回的是True。期望的是只有metadate被设置为windows的主机返回True,其他应该都是False。现在来分析原因。

看代码,返回False只有一种情况:主机的某一个metadata和image的metadata不匹配。返回True,除了主机的所有metadata和image的metadata都匹配会返回;还有一种情况在代码的continue语句中,即在except中,该异常是AttributeError。就是说主机的所有metadata只要是或者和image的metadata都匹配或者不存在于image的metadata中,就会执行完所有的while循环,返回True。

检查不期望被filter通过的主机的metadata,nova aggregate-show aggregate_id 发现其他主机组没有配置os_type。用命令nova aggregate-set-metadatew aggregate_id给其他主机组添加属性:os_type=linux

再用该image生成vm,可以被正确调度到windows主机组。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-01-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 后端云 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档