0

我将此作为问题发布,以报告我遇到的其他问题似乎未涵盖的问题(和解决方法)。它可能非常特定于我正在使用的软件设置,但如果它有帮助......

这是在已成功运行多年的单节点配置上(Ubuntu 12.04、Havana OpenStack),但这是我一段时间以来第一次尝试创建新的 VM 映像。

我运行的命令是这样的:

cinder create 50 --display_name bionic-test-annalist-50Gb \
                 --volume_type lvm-scsi \
                 --image-id 5121d3e9-ef3d-4ff9-a5b9-f2f31c08cbbe \
                 --availability-zone nova

之后我看到了这个卷状态:

root@seldon:/etc/cinder# cinder list
+--------------------------------------+--------+-----------------------+------+-------------+----------+--------------------------------------+
|                  ID                  | Status |      Display Name     | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+--------+-----------------------+------+-------------+----------+--------------------------------------+
| 26277f8f-e0cd-43e7-8e5c-c42b0be21706 | in-use |  dhoxss-annalist-50Gb |  50  |   lvm-scsi  |   true   | d436f20c-5f8f-47cb-9ad5-eacaf6bda882 |
| 852fd771-71ec-4d0a-ae62-b48b5e35ff93 | in-use |   demo-annalist-50Gb  |  50  |   lvm-scsi  |   true   | eac53b50-54f3-4e93-804d-91569e1ed337 |
| abe7e7e6-502c-48b5-95ef-207891076e11 | in-use |   test-databank-50Gb  |  50  |   lvm-scsi  |   true   | 367bddfe-da43-40f2-a23c-75a5dac5225e |
| afa05ae4-e956-446b-bb26-a1439502435c | error  |  bionic-annalist-50Gb |  50  |   lvm-scsi  |  false   |                                      |
| ce7e0d7b-dfe3-4c8a-a541-91d9b6b388d9 | in-use | fast-performance-50Gb |  50  |   lvm-scsi  |   true   | 233a8924-cfd0-4f2c-a242-d596f1bb0cee |
| da9a5222-246e-4697-b10e-02c9a912d4b6 | in-use |   dev-annalist-50Gb   |  50  |   lvm-scsi  |   true   | 463ffed0-7a31-467b-9ec6-a5acdbf72723 |
+--------------------------------------+--------+-----------------------+------+-------------+----------+--------------------------------------+

Cinder 日志文件(我认为是/var/log/cinder/cinder-scheduler.log)显示了这一点:

2018-10-10 18:29:49.803 2111 WARNING cinder.scheduler.host_manager [req-4d12534f-abcd-499f-99cf-5f49d0308439 c570590c61be4ae5819c9b2d93986df2 1e701a6ab66141b9a64bfd963e301bc6] volume service is down or disabled. (host: seldon)
2018-10-10 18:29:49.804 2111 WARNING cinder.scheduler.host_manager [req-4d12534f-abcd-499f-99cf-5f49d0308439 c570590c61be4ae5819c9b2d93986df2 1e701a6ab66141b9a64bfd963e301bc6] volume service is down or disabled. (host: seldon@lvmdriver-scsi)
2018-10-10 18:29:49.805 2111 ERROR cinder.volume.flows.create_volume [req-4d12534f-abcd-499f-99cf-5f49d0308439 c570590c61be4ae5819c9b2d93986df2 1e701a6ab66141b9a64bfd963e301bc6] Failed to schedule_create_volume: No valid host was found.

特别注意:Failed to schedule_create_volume: No valid host was found.

并且服务列表确认该服务没有运行。

root@seldon:/etc/cinder# cinder service-list
+------------------+-----------------------+------+---------+-------+----------------------------+
|      Binary      |          Host         | Zone |  Status | State |         Updated_at         |
+------------------+-----------------------+------+---------+-------+----------------------------+
| cinder-scheduler |         seldon        | nova | enabled |   up  | 2018-10-10T17:30:07.000000 |
|  cinder-volume   |         seldon        | nova | enabled |  down | 2014-03-11T14:17:02.000000 |
|  cinder-volume   |  seldon@lvmdriver-sas | nova | enabled |   up  | 2018-10-10T17:30:12.000000 |
|  cinder-volume   | seldon@lvmdriver-scsi | nova | enabled |  down | 2018-10-10T17:27:55.000000 |
+------------------+-----------------------+------+---------+-------+----------------------------+

鉴于该系统以前可以正常工作,并且现有的虚拟机仍然可以正常工作,这是怎么回事?谷歌搜索没有发现任何修复。

4

1 回答 1

0

TL;DR:tgt-admin --show在其输出中添加了非 ASCII 字符,这导致 Cinder 中的输出解析器出错。代码补丁会跳过非 ASCII 字符的行(见下文)。


在日志文件中挖掘发现了这份报告:

2018-10-10 17:57:17.067 6970 ERROR cinder.service [req-a950a5bb-4f24-42dd-8ffc-4b2dd9153659 None None] Unhandled exception
2018-10-10 17:57:17.067 6970 TRACE cinder.service Traceback (most recent call last):
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/service.py", line 228, in _start_child
2018-10-10 17:57:17.067 6970 TRACE cinder.service     self._child_process(wrap.server)
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/service.py", line 205, in _child_process
2018-10-10 17:57:17.067 6970 TRACE cinder.service     launcher.run_server(server)
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/service.py", line 96, in run_server
2018-10-10 17:57:17.067 6970 TRACE cinder.service     server.start()
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/service.py", line 385, in start
2018-10-10 17:57:17.067 6970 TRACE cinder.service     self.manager.init_host()
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/volume/manager.py", line 209, in init_host
2018-10-10 17:57:17.067 6970 TRACE cinder.service     self.driver.ensure_export(ctxt, volume)
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/volume/drivers/lvm.py", line 525, in ensure_export
2018-10-10 17:57:17.067 6970 TRACE cinder.service     old_name=old_name)
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/volume/drivers/lvm.py", line 444, in _create_tgtadm_target
2018-10-10 17:57:17.067 6970 TRACE cinder.service     old_name=old_name)
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/brick/iscsi/iscsi.py", line 231, in create_iscsi_target
2018-10-10 17:57:17.067 6970 TRACE cinder.service     if not self._verify_backing_lun(iqn, tid):
2018-10-10 17:57:17.067 6970 TRACE cinder.service   File "/usr/lib/python2.7/dist-packages/cinder/brick/iscsi/iscsi.py", line 114, in _verify_backing_lun
2018-10-10 17:57:17.067 6970 TRACE cinder.service     if iqn in line and "Target %s" % tid in line:
2018-10-10 17:57:17.067 6970 TRACE cinder.service UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 0: ordinal not in range(128)
2018-10-10 17:57:17.067 6970 TRACE cinder.service
2018-10-10 17:57:17.088 6965 INFO cinder.service [-] Child 6970 exited with status 2
2018-10-10 17:57:17.088 6965 INFO cinder.service [-] _wait_child 1
2018-10-10 17:57:17.089 6965 INFO cinder.service [-] wait wrap.failed True

注意错误:UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 0.

报告错误处的代码如下所示:

    for line in lines:
        if iqn in line and "Target %s" % tid in line:
            capture = True
        if capture:
            target_info.append(line)
        if iqn not in line and 'Target ' in line:
            capture = False

查看堆栈跟踪和源代码,我发现代码试图解析由tgt-admin --show(参见方法TgtAdm._get_target,从create_iscsi_target(大约第 220 行)调用,然后调用_verify_backing_lun发生错误的位置)生成的输出。这是通过手动运行命令来检查的less,并在输出末尾注明额外的字符。

我的补丁/修复是以try块的形式向输出解析器添加测试,因此:

    for line in lines:
        try:
            line.decode('ascii')
        except UnicodeDecodeError:
            continue # @@@@ skip lines with non-ASCII characters
        if iqn in line and "Target %s" % tid in line:
            capture = True
        if capture:
            target_info.append(line)
        if iqn not in line and 'Target ' in line:
            capture = False

这并不理想,但它让我摆脱了原来的困境。

于 2018-10-11T10:19:20.050 回答