Openstack CPU/disk/network QoS機能


OpenstackではInstance Recource Quotaというfeatureが早くから追加されていますが、このfeatureをすべてテストしたことはありません.今日はhavanaバージョンでこの機能をテストしました.
まず、このfeatureのコミュニティでのwikiは以下の通りです.
https://wiki.openstack.org/wiki/InstanceResourceQuota
テストの過程で、このwikiの一部の情報はコードと一致していないことが分かった.
全体的にこのfeatureの機能はcgroupとtcによって実現される.cgroupはCPU/diskのIO,tcを制限network IOを制限する.
まずCPU制限を見て、現在パラメータをサポートしています.
quota:cpu_shares
quota:cpu_period
quota:cpu_quota

私はquota:cpuだけをテストしました.period、テスト手順は以下の通りです.
nova flavor-key  test_resource_quato set quota:cpu_period=110000

CLIによりflavorのExtra Specsが設定.もちろんdashboardで設定することもできますが、現在は以下のバグが存在し、実際に設定することはできますが、dashboardではリダイレクトエラーが発生します.
https://bugs.launchpad.net/horizon/+bug/1268860
次に、このflavorを使用して虚機を起動し、計算ノードでcgroupを次のように表示します.
[root@ci91szcmp005vcpu0]# pwd
/cgroup/cpu/libvirt/qemu/instance-00000010/vcpu0
[root@ci91szcmp005vcpu0]# cat cpu.cfs_period_us
110000
[root@ci91szcmp005vcpu0]# cd ../vcpu1/
[root@ci91szcmp005vcpu1]# cat cpu.cfs_period_us
110000

デフォルトのcpu periodは100000で、ここでは110000に変更され、機能しています.
関連コードは次のとおりです.
https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L3012-3019
Network IOのテストについて以前blogを書いたことがありますが、havanaバージョンではあまり変わっていませんが、tcの役割オブジェクトがvnetXXからtapデバイスに変わりました.ここでは、以下のblogを参照してください.
http://blog.csdn.net/matt_mao/article/details/15339729
また、現在サポートされているnetwork IOのパラメータは以下の通りです.
quota:vif_inbound_average
quota:vif_inbound_peak
quota:vif_inbound_burst
quota:vif_outbound_average
quota:vif_outbound_peak
quota:vif_outbound_burst

関連コードは次のとおりです.
https://github.com/openstack/nova/blob/master/nova/virt/libvirt/designer.py#L126-133
Disk IOのテスト中に次のエラーログが見つかりました.
2014-01-1603:25:18.9923158 ERROR nova.compute.manager [req-8e364bca-9313-4c38-a900-34d2b7f3f700 ad3955246b8d45c8a808b83e4d51c246 88f530c7b2484336824c87801d6d4950] [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] Error: unsupported configuration: block I/O throttling not supported withthisQEMU binary
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] Traceback (most recent call last):
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1037, in _build_instance
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     set_access_ip=set_access_ip)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1410, in _spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     LOG.exception(_('Instance failed to spawn'), instance=instance)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1407, in _spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     block_device_info)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 2070, in spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     block_device_info, context=context)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3205, in _create_domain_and_network
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain = self._create_domain(xml, instance=instance, power_on=power_on)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3148, in _create_domain
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain.XMLDesc(0))
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3143, in _create_domain
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain.createWithFlags(launch_flags)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 187, in doit
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     result = proxy_call(self._autowrap, f, *args, **kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 147, in proxy_call
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     rv = execute(f,*args,**kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 76, in tworker
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     rv = meth(*args,**kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib64/python2.6/site-packages/libvirt.py", line 708, in createWithFlags
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     ifret == -1: raise libvirtError ('virDomainCreateWithFlags() failed', dom=self)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] libvirtError: unsupported configuration: block I/O throttling not supported withthisQEMU binary
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]

qemuのバグのためか、まだ正常に動作していません.
https://www.redhat.com/archives/libvirt-users/2012-December/msg00008.html