-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gateway only: Ensure launch and request timeouts are in sync (#5317)
Prior to this change, the request timeout for a Gateway request was synchronized with KERNEL_LAUNCH_TIMEOUT only if KLT was greater. However, the two are closely associated and KLT should be adjusted if the configurable request_timeout is greater. This change ensures that the two values are synchronized to the greater value. It changes the two configurable timeouts to default to 40 (to match that of KLT) and removes the 2-second pad, since that wasn't helpful and only confused the situation. These changes were prompted by this issue: jupyter-server/enterprise_gateway#792
- Loading branch information
1 parent
fcf3070
commit 573adc3
Showing
2 changed files
with
17 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ def _kernelspecs_endpoint_default(self): | |
def _kernelspecs_resource_endpoint_default(self): | ||
return os.environ.get(self.kernelspecs_resource_endpoint_env, self.kernelspecs_resource_endpoint_default_value) | ||
|
||
connect_timeout_default_value = 60.0 | ||
connect_timeout_default_value = 40.0 | ||
connect_timeout_env = 'JUPYTER_GATEWAY_CONNECT_TIMEOUT' | ||
connect_timeout = Float(default_value=connect_timeout_default_value, config=True, | ||
help="""The time allowed for HTTP connection establishment with the Gateway server. | ||
|
@@ -112,7 +112,7 @@ def _kernelspecs_resource_endpoint_default(self): | |
def connect_timeout_default(self): | ||
return float(os.environ.get('JUPYTER_GATEWAY_CONNECT_TIMEOUT', self.connect_timeout_default_value)) | ||
|
||
request_timeout_default_value = 60.0 | ||
request_timeout_default_value = 40.0 | ||
request_timeout_env = 'JUPYTER_GATEWAY_REQUEST_TIMEOUT' | ||
request_timeout = Float(default_value=request_timeout_default_value, config=True, | ||
help="""The time allowed for HTTP request completion. (JUPYTER_GATEWAY_REQUEST_TIMEOUT env var)""") | ||
|
@@ -226,18 +226,20 @@ def gateway_enabled(self): | |
|
||
# Ensure KERNEL_LAUNCH_TIMEOUT has a default value. | ||
KERNEL_LAUNCH_TIMEOUT = int(os.environ.get('KERNEL_LAUNCH_TIMEOUT', 40)) | ||
os.environ['KERNEL_LAUNCH_TIMEOUT'] = str(KERNEL_LAUNCH_TIMEOUT) | ||
|
||
LAUNCH_TIMEOUT_PAD = int(os.environ.get('LAUNCH_TIMEOUT_PAD', 2)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kevin-bates
Author
Member
|
||
|
||
def init_static_args(self): | ||
"""Initialize arguments used on every request. Since these are static values, we'll | ||
perform this operation once. | ||
""" | ||
# Ensure that request timeout is at least "pad" greater than launch timeout. | ||
if self.request_timeout < float(GatewayClient.KERNEL_LAUNCH_TIMEOUT + GatewayClient.LAUNCH_TIMEOUT_PAD): | ||
self.request_timeout = float(GatewayClient.KERNEL_LAUNCH_TIMEOUT + GatewayClient.LAUNCH_TIMEOUT_PAD) | ||
# Ensure that request timeout and KERNEL_LAUNCH_TIMEOUT are the same, taking the | ||
# greater value of the two. | ||
if self.request_timeout < float(GatewayClient.KERNEL_LAUNCH_TIMEOUT): | ||
self.request_timeout = float(GatewayClient.KERNEL_LAUNCH_TIMEOUT) | ||
elif self.request_timeout > float(GatewayClient.KERNEL_LAUNCH_TIMEOUT): | ||
GatewayClient.KERNEL_LAUNCH_TIMEOUT = int(self.request_timeout) | ||
# Ensure any adjustments are reflected in env. | ||
os.environ['KERNEL_LAUNCH_TIMEOUT'] = str(GatewayClient.KERNEL_LAUNCH_TIMEOUT) | ||
|
||
self._static_args['headers'] = json.loads(self.headers) | ||
if 'Authorization' not in self._static_args['headers'].keys(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@kevin-bates are you sure LAUNCH_TIMEOUT_PAD wasn't helpful? I'm thinking that since KERNEL_LAUNCH_TIMEOUT is forwarded to EG, the request_timeout should always be bigger. I'm thinking at the following scenario: