我已经到处寻找解决方案,似乎大多数人都遇到了服务根本没有运行或无法连接的问题,我没有遇到问题。
遵循 Ussuri OpenStack 版本的 Keystone 安装指南后,我收到此错误。
完整的错误是:
Failed to discover available identity versions when contacting http://xxx.xxx.xxx.xxx:5000/v3. Attempting to parse version from URL.
Unexpected exception for http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
这是由运行以下命令引起的:openstack domain create --description 'Example' example
如果我 curl /v3 URL,我得到:
{
"version": {
"id": "v3.14",
"status": "stable",
"updated": "2020-04-07T00:00:00Z",
"links": [
{
"rel": "self",
"href": "http://xxx.xxx.xxx.xxx:5000/v3/"
}
],
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.identity-v3+json"
}
]
}
}
当我尝试获取 /v3/auth/tokens URL 时,我得到了响应:
< HTTP/1.1 401 UNAUTHORIZED
< Date: Tue, 22 Sep 2020 17:21:26 GMT
< Server: Apache/2.4.37 (centos) OpenSSL/1.1.1c mod_wsgi/4.6.4 Python/3.6
< WWW-Authenticate: Keystone uri="http://xxx.xxx.xxx.xxx:5000/v3"
< Content-Length: 109
< Vary: X-Auth-Token
< x-openstack-request-id: req-3ac7aec3-1a0e-4fdd-a5ee-2ffecbd15151
< Content-Type: application/json
<
{"error":{"code":401,"message":"The request you have made requires authentication.","title":"Unauthorized"}}
在 /var/log/keystone/keystone.log 的 keystone.log 中,有一条消息说您发出的请求也需要身份验证。
与运行 openstack 命令相对应,我在日志中没有收到任何错误。
这也是我设置的 OpenStack 环境变量:
export OS_USERNAME=admin
export OS_PASSWORD="***"
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL="http://xxx.xxx.xxx.xxx:5000/v3"
export OS_IDENTITY_API_VERSION=3
密码中确实有一些标点符号,我想这可能是问题所在,但我不想不得不从头开始重新安装来测试一个长远的假设。
任何帮助是极大的赞赏。
以下是使用--debug
标志运行 openstack 命令的输出:
START with options: domain create --debug --description Example example
options: Namespace(access_key='', access_secret='***', access_token='***', access_token_endpoint='', access_token_type='', application_credential_id='', application_credential_name='', application_credential_secret='***', auth_methods='', auth_type='', auth_url='http://xxx.xxx.xxx.xxx:5000/v3', cacert=None, cert='', client_id='', client_secret='***', cloud='', code='', consumer_key='', consumer_secret='***', debug=True, default_domain='default', default_domain_id='', default_domain_name='', deferred_help=False, discovery_endpoint='', domain_id='', domain_name='', endpoint='', identity_provider='', insecure=None, interface='public', key='', log_file=None, openid_scope='', os_beta_command=False, os_compute_api_version='', os_identity_api_version='3', os_image_api_version='', os_network_api_version='', os_object_api_version='', os_project_id=None, os_project_name=None, os_volume_api_version='', passcode='', password='***', profile='', project_domain_id='', project_domain_name='default', project_id='', project_name='admin', protocol='', redirect_uri='', region_name='', remote_project_domain_id='', remote_project_domain_name='', remote_project_id='', remote_project_name='', service_provider='', system_scope='', timing=False, token='***', trust_id='', user_domain_id='', user_domain_name='default', user_id='', username='admin', verbose_level=3, verify=None)
Auth plugin password selected
auth_config_hook(): {'api_timeout': None, 'verify': True, 'cacert': None, 'cert': None, 'key': None, 'baremetal_status_code_retries': '5', 'baremetal_introspection_status_code_retries': '5', 'image_status_code_retries': '5', 'disable_vendor_agent': {}, 'interface': 'public', 'floating_ip_source': 'neutron', 'image_api_use_tasks': False, 'image_format': 'qcow2', 'message': '', 'network_api_version': '2', 'object_store_api_version': '1', 'secgroup_source': 'neutron', 'status': 'active', 'auth': {'user_domain_name': 'default', 'project_domain_name': 'default', 'project_name': 'admin'}, 'verbose_level': 3, 'deferred_help': False, 'debug': True, 'default_domain': 'default', 'timing': False, 'auth_url': 'http://xxx.xxx.xxx.xxx:5000/v3', 'username': 'admin', 'password': '***', 'beta_command': False, 'identity_api_version': '3', 'region_name': '', 'auth_type': 'password', 'networks': []}
defaults: {'api_timeout': None, 'verify': True, 'cacert': None, 'cert': None, 'key': None, 'auth_type': 'password', 'baremetal_status_code_retries': 5, 'baremetal_introspection_status_code_retries': 5, 'image_status_code_retries': 5, 'disable_vendor_agent': {}, 'interface': None, 'floating_ip_source': 'neutron', 'image_api_use_tasks': False, 'image_format': 'qcow2', 'message': '', 'network_api_version': '2', 'object_store_api_version': '1', 'secgroup_source': 'neutron', 'status': 'active'}
cloud cfg: {'api_timeout': None, 'verify': True, 'cacert': None, 'cert': None, 'key': None, 'baremetal_status_code_retries': '5', 'baremetal_introspection_status_code_retries': '5', 'image_status_code_retries': '5', 'disable_vendor_agent': {}, 'interface': 'public', 'floating_ip_source': 'neutron', 'image_api_use_tasks': False, 'image_format': 'qcow2', 'message': '', 'network_api_version': '2', 'object_store_api_version': '1', 'secgroup_source': 'neutron', 'status': 'active', 'auth': {'user_domain_name': 'default', 'project_domain_name': 'default', 'project_name': 'admin'}, 'verbose_level': 3, 'deferred_help': False, 'debug': True, 'default_domain': 'default', 'timing': False, 'auth_url': 'http://xxx.xxx.xxx.xxx:5000/v3', 'username': 'admin', 'password': '***', 'beta_command': False, 'identity_api_version': '3', 'region_name': '', 'auth_type': 'password', 'networks': []}
compute API version 2.1, cmd group openstack.compute.v2
identity API version 3, cmd group openstack.identity.v3
image API version 2, cmd group openstack.image.v2
network API version 2, cmd group openstack.network.v2
object_store API version 1, cmd group openstack.object_store.v1
volume API version 3, cmd group openstack.volume.v3
neutronclient API version 2, cmd group openstack.neutronclient.v2
command: domain create -> openstackclient.identity.v3.domain.CreateDomain (auth=True)
Auth plugin password selected
auth_config_hook(): {'api_timeout': None, 'verify': True, 'cacert': None, 'cert': None, 'key': None, 'baremetal_status_code_retries': '5', 'baremetal_introspection_status_code_retries': '5', 'image_status_code_retries': '5', 'disable_vendor_agent': {}, 'interface': 'public', 'floating_ip_source': 'neutron', 'image_api_use_tasks': False, 'image_format': 'qcow2', 'message': '', 'network_api_version': '2', 'object_store_api_version': '1', 'secgroup_source': 'neutron', 'status': 'active', 'auth': {'user_domain_name': 'default', 'project_domain_name': 'default', 'project_name': 'admin'}, 'additional_user_agent': [('osc-lib', '2.0.0')], 'verbose_level': 3, 'deferred_help': False, 'debug': True, 'default_domain': 'default', 'timing': False, 'auth_url': 'http://xxx.xxx.xxx.xxx:5000/v3', 'username': 'admin', 'password': '***', 'beta_command': False, 'identity_api_version': '3', 'region_name': '', 'auth_type': 'password', 'networks': []}
Using auth plugin: password
Using parameters {'auth_url': 'http://xxx.xxx.xxx.xxx:5000/v3', 'project_name': 'admin', 'project_domain_name': 'default', 'username': 'admin', 'user_domain_name': 'default', 'password': '***'}
Get auth_ref
REQ: curl -g -i -X GET http://xxx.xxx.xxx.xxx:5000/v3 -H "Accept: application/json" -H "User-Agent: openstacksdk/0.46.0 keystoneauth1/4.0.0 python-requests/2.22.0 CPython/3.6.8"
Failed to discover available identity versions when contacting http://xxx.xxx.xxx.xxx:5000/v3. Attempting to parse version from URL.
Making authentication request to http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
Unexpected exception for http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests/models.py", line 379, in prepare_url
scheme, auth, host, port, path, query, fragment = parse_url(url)
File "/usr/lib/python3.6/site-packages/urllib3/util/url.py", line 398, in parse_url
return six.raise_from(LocationParseError(source_url), None)
File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/keystoneauth1/session.py", line 1004, in _send_request
resp = self.session.request(method, url, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 519, in request
prep = self.prepare_request(req)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 462, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python3.6/site-packages/requests/models.py", line 313, in prepare
self.prepare_url(url, params)
File "/usr/lib/python3.6/site-packages/requests/models.py", line 381, in prepare_url
raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/cliff/app.py", line 393, in run_subcommand
self.prepare_to_run_command(cmd)
File "/usr/lib/python3.6/site-packages/osc_lib/shell.py", line 493, in prepare_to_run_command
self.client_manager.auth_ref
File "/usr/lib/python3.6/site-packages/osc_lib/clientmanager.py", line 202, in auth_ref
self._auth_ref = self.auth.get_auth_ref(self.session)
File "/usr/lib/python3.6/site-packages/keystoneauth1/identity/generic/base.py", line 208, in get_auth_ref
return self._plugin.get_auth_ref(session, **kwargs)
File "/usr/lib/python3.6/site-packages/keystoneauth1/identity/v3/base.py", line 184, in get_auth_ref
authenticated=False, log=False, **rkwargs)
File "/usr/lib/python3.6/site-packages/keystoneauth1/session.py", line 1131, in post
return self.request(url, 'POST', **kwargs)
File "/usr/lib/python3.6/site-packages/keystoneauth1/session.py", line 913, in request
resp = send(**kwargs)
File "/usr/lib/python3.6/site-packages/keystoneauth1/session.py", line 1024, in _send_request
raise exceptions.UnknownConnectionError(msg, e)
keystoneauth1.exceptions.connection.UnknownConnectionError: Unexpected exception for http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
clean_up CreateDomain: Unexpected exception for http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens: Failed to parse: http://xxx.xxx.xxx.xxx:5000/v3/auth/tokens
END return value: 1
我还检查了 keystone wsgi 实例是否正在运行。一切似乎都已经到位,尽管我确定我错过了一些东西。我就是找不到。
真的不知道这是否有联系,但是关于此类解析问题存在一个问题(已关闭)。见:https ://github.com/psf/requests/issues/5476
我可以使用重现该问题
python3 -c "import requests; requests.get('https://google.com');"
在 CentOS 8 上使用 Python 3.6.8 [GCC 8.3.1 20191121],但是当使用 Python 3.8.0(通过 pip 安装的请求)时,它不会引发异常。希望这可以帮助。
编辑:
python3-six python3-urllib3
使用较新版本重新安装时可以正常工作。来源: https ://bugzilla.redhat.com/show_bug.cgi?id=1787227