Description
Traceback:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "/usr/local/lib/python2.7/dist-packages/flask_login/utils.py", line 261, in decorated_view
return func(*args, **kwargs)
File "/home/h37/X_Server/ServerController/app/views/user_view.py", line 78, in user_center
navigations=view_util.get_navi_path(proj_name),
File "/home/h37/X_Server/ServerController/app/views/view_util.py", line 98, in get_navi_path
branches = KubeCtl().get_project_hold_server_branches(project_name)
File "/home/h37/X_Server/ServerController/app/kubectl/KubeCtl.py", line 381, in get_project_hold_server_branches
pod_lst = self.v1_api.list_namespaced_pod(project_name)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/client/apis/core_v1_api.py", line 12372, in list_namespaced_pod
(data) = self.list_namespaced_pod_with_http_info(namespace, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/client/apis/core_v1_api.py", line 12472, in list_namespaced_pod_with_http_info
collection_formats=collection_formats)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/client/api_client.py", line 334, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/client/api_client.py", line 168, in __call_api
_request_timeout=_request_timeout)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/stream/stream.py", line 31, in _intercept_request_call
return ws_client.websocket_call(config, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kubernetes/stream/ws_client.py", line 260, in websocket_call
raise ApiException(status=0, reason=str(e))
ApiException: (0)
Reason: Handshake status 200 OK
In my flask application, using multithread mode.
And, if one request need execute a connect_post_namespaced_pod_exec function (I invoke it by using stream.). The connect_post_namespaced_pod_exec will cost minutes to finished. While it is not finished, some other normal request comming, for example, list_namespaced_pod.
It throws the trace shown above. I find the stream implement is replace the api_client.request by ws_client like:
`
def stream(func, *args, **kwargs):
"""Stream given API call using websocket"""
def _intercept_request_call(*args, **kwargs):
# old generated code's api client has config. new ones has
# configuration
try:
config = func.__self__.api_client.configuration
except AttributeError:
config = func.__self__.api_client.config
return ws_client.websocket_call(config, *args, **kwargs)
prev_request = func.__self__.api_client.request
try:
func.__self__.api_client.request = _intercept_request_call
return func(*args, **kwargs)
finally:
func.__self__.api_client.request = prev_request
`
So, when connect_post_namespaced_pod_exec not finished, later requests will throw trace.
My question:
It is kubernetes client does not support multi-thread scene?
Or,it there a method to solve this problem.
My bottom line plan is to execute commands from os.system('cmd'). It will limit my flask application must be deploy on cluster master node.