聯繫 http://xxx.xxx.xxx.xxx:5000/v3 時發現可用身份版本失敗
我已經到處尋找解決方案,似乎大多數人都遇到了服務根本沒有執行或無法連接的問題,我沒有遇到問題。
遵循 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');"
使用 Python 3.6.8
$$ GCC 8.3.1 20191121 $$在 CentOS 8 上,但是當使用 Python 3.8.0(通過 pip 安裝的請求)時,它不會拋出異常。希望這可以幫助。 編輯:
python3-six python3-urllib3
使用較新版本重新安裝時可以正常工作。來源: https ://bugzilla.redhat.com/show_bug.cgi?id=1787227