0

我正在尝试使用打包器在 openstack 上构建 centos 映像。由于某种原因,构建在脚本中间终止,我无法找出问题。

此外,我一目了然找不到任何日志。

这是我的打包脚本和错误日志。

打包脚本

{
  "builders": [
 {
   "availability_zone": "nova",
   "domain_id": "xxxx",
   "flavor": "m1.tiny",
   "identity_endpoint": "http://xxx:5000/v3",
   "image_name": "centos",
   "image_visibility": "private",
   "image_members": "myname",
   "networks": "xxx-xxx-xxxx",
   "password": "mypassword",
   "region": "RegionOne",
   "source_image": "17987fc7-e5af-487f-ae74-754ade318824",
   "ssh_keypair_name": "mykeypair",
   "ssh_private_key_file": "/root/.ssh/id_rsa",
   "ssh_username": "mysshusername",
   "tenant_name": "admin",
   "type": "openstack",
   "username": "myusername"
 }
 ],
 "provisioners": [
 {
   "script": "setup-centos.sh",
   "type": "shell"
 } 
 ]
}

错误日志

...
2018/07/27 13:01:31 packer: 2018/07/27 13:01:31 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:33 packer: 2018/07/27 13:01:33 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:35 packer: 2018/07/27 13:01:35 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:37 packer: 2018/07/27 13:01:37 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:39 packer: 2018/07/27 13:01:39 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:41 packer: 2018/07/27 13:01:41 Waiting for image creation status: SAVING (25%)
2018/07/27 13:01:43 ui error: ==> openstack: Error waiting for image: Resource not found
==> openstack: Error waiting for image: Resource not found
2018/07/27 13:01:43 ui: ==> openstack: Terminating the source server: 1034619b-4dc9-45d1-b160-20290e0c4c08 ...
==> openstack: Terminating the source server: 1034619b-4dc9-45d1-b160-20290e0c4c08 ...
2018/07/27 13:01:43 packer: 2018/07/27 13:01:43 Waiting for state to become: [DELETED]
2018/07/27 13:01:44 packer: 2018/07/27 13:01:44 Waiting for state to become: [DELETED] currently SHUTOFF (0%)
2018/07/27 13:01:46 packer: 2018/07/27 13:01:46 [INFO] 404 on ServerStateRefresh, returning DELETED
2018/07/27 13:01:46 [INFO] (telemetry) ending openstack
2018/07/27 13:01:46 [INFO] (telemetry) found error: Error waiting for image: Resource not found
2018/07/27 13:01:46 ui error: Build 'openstack' errored: Error waiting for image: Resource not found
2018/07/27 13:01:46 Builds completed. Waiting on interrupt barrier...
2018/07/27 13:01:46 machine readable: error-count []string{"1"}
2018/07/27 13:01:46 ui error:
==> Some builds didn't complete successfully and had errors:
2018/07/27 13:01:46 machine readable: openstack,error []string{"Error waiting for image: Resource not found"}
2018/07/27 13:01:46 ui error: --> openstack: Error waiting for image: Resource not found
2018/07/27 13:01:46 ui:
==> Builds finished but no artifacts were created.
2018/07/27 13:01:46 [INFO] (telemetry) Finalizing.
Build 'openstack' errored: Error waiting for image: Resource not found


==> Some builds didn't complete successfully and had errors:
--> openstack: Error waiting for image: Resource not found


==> Builds finished but no artifacts were created.
2018/07/27 13:01:47 waiting for all plugin processes to complete...
2018/07/27 13:01:47 /root/pack/packer: plugin process exited
2018/07/27 13:01:47 /root/pack/packer: plugin process exited

提前致谢。

4

1 回答 1

0

我在glance api中发现了错误日志。

2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver Traceback (most recent call last):
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1642, in snapshot
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     purge_props=False)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/api.py", line 132, in update
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     purge_props=purge_props)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 733, in update
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     _reraise_translated_image_exception(image_id)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 1050, in _reraise_translated_image_exception
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     six.reraise(type(new_exc), new_exc, exc_trace)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 731, in update
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     image = self._update_v2(context, sent_service_image_meta, data)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 745, in _update_v2
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     image = self._add_location(context, image_id, location)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 630, in _add_location
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     location, {})
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 168, in call
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     result = getattr(controller, method)(*args, **kwargs)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 340, in add_location
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     response = self._send_image_update_request(image_id, add_patch)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 535, in inner
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     return RequestIdProxy(wrapped(*args, **kwargs))
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 324, in _send_image_update_request
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     data=json.dumps(patch_body))
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 294, in patch
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     return self._request('PATCH', url, **kwargs)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 277, in _request
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     resp, body_iter = self._handle_response(resp)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver   File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 107, in _handle_response
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver     raise exc.from_response(resp, resp.content)
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver ImageNotAuthorized: Not authorized for image 9eb18ad3-ba29-4240-a7eb-5c8e87ef40b5.
2018-08-02 18:37:56.030 7 ERROR nova.virt.libvirt.driver 

此错误与glance api 设置有关。

所以,我改变了glance-api.conf

[DEFAULT]
...
show_multiple_locations = True

之后,一切正常!

于 2018-08-03T05:26:57.603 回答