• openstack 的 policy 问题。


    想写nova的policy的实现, 但是发现网上,有人写的很不错了。

    ref: http://blog.csdn.net/hackerain/article/details/8241691

    但是,policy本身存在一点问题,其他文章没有介绍。

    policy的加载是同步的,每次loader的时候,都会检测,文件是否修改,修改则重新加载。

    建议策略: 改成异步监听policy的文件, 文件修改是加载。 实现时,注意 enforce函数 和 加载函数的 race。

    policy的同步缺陷可能导致的问题。

    当我们要在magnum/api/controllers/v1/bay.py 中调用这个policy.enfore,不同的位置调用,会导致web server的性能不同。

    1. 

     1 class BaysController(rest.RestController):
     2     """REST controller for Bays."""
     3     def __init__(self):
     4         super(BaysController, self).__init__()
     5 
     6     ...
     7 
     8     @wsme_pecan.wsexpose(Bay, types.uuid_or_name)
     9     def get_one(self, bay_ident):
    10         policy.enfore("bay:get_one", pecan.request.contex)
    11         if self.from_bays:
    12             raise exception.OperationNotPermitted
    13 
    14         rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
    15 
    16         return Bay.convert_with_links(rpc_bay)

    2.

     1 class BaysController(rest.RestController):
     2     """REST controller for Bays."""
     3     def __init__(self):
     4         super(BaysController, self).__init__()
     5 
     6     ...
     7 
     8     @wsme_pecan.wsexpose(Bay, types.uuid_or_name)
     9     def get_one(self, bay_ident):
    10         if self.from_bays:
    11             raise exception.OperationNotPermitted
    12         policy.enfore("bay:get_one", pecan.request.contex)
    13 
    14         rpc_bay = api_utils.get_rpc_resource('Bay', bay_ident)
    15 
    16         return Bay.convert_with_links(rpc_bay)

    magnum代码中, 和同事讨论采用1的方法,提前(第10行)做policy 的enforce。

    在淘宝双11的节奏中,当请求量很大时,尤其是在self.from_bays 的条件满足的情况下, 由于 policy 自身的实现(请查看policy的代码),导致服务器的压力增大。

  • 相关阅读:
    samba linux windows 请联系管理员
    centos chrome
    centos6.5 中文
    Hibernate 中update hql语句
    嵌入式Linux应用程序开发环境搭建记录
    JDK-windows7环境变量配置-亲测版本 以及HelloWorld
    windows tcp端口映射或端口转发
    VMWare Workstation:局域网PC连接虚拟机里的远程桌面或端口
    正则提取文本中的颜色值 #xxxx,不严谨版本
    Python 2.7.3 urllib2.urlopen 获取网页出现乱码解决方案
  • 原文地址:https://www.cnblogs.com/shaohef/p/4527436.html
Copyright © 2020-2023  润新知