-
Notifications
You must be signed in to change notification settings - Fork 70
Add support for setting a maximum session age in RemoteModuleBase #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One typo nit pick and a couple of suggestions
# If the max session age is less then 0 then reuse the existing con channel | ||
elif self._connection.max_session_age < 0: | ||
pass | ||
|
||
# If the current time is greater than the conn channel timeout then construct a | ||
# new channel | ||
elif datetime.now() - self._current_conn_time > self._max_conn_delta: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The elif...pass
is a bit confusing. I'd suggest merging these into a single elif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I was trying to be explicit but just made it more confusing
def test_remote_initializer_always_new_channel( | ||
sample_task_model_id, open_port, protocol | ||
): | ||
"""Test to ensure RemoteModule Initializer negative max connection age always creates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Test to ensure RemoteModule Initializer negative max connection age always creates | |
"""Test to ensure RemoteModule Initializer zero max connection age always creates |
remote_model = remote_initializer.init(remote_config) | ||
assert isinstance(remote_model, ModuleBase) | ||
|
||
# Run RemoteModule Request twice to ensure the channel is retained. Run the second one with a small sleep to ensure the third request gets a new object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new definition of "small sleep!" I worry this is a little error prone with sleep-based behavior. Could we use a mock to patch over the time.time
function to make it appear as "timed out" on the third call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call on mock! Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, ship it!
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
9675378
to
35650b3
Compare
What this PR does / why we need it:
This PR adds support for setting a maximum session/channel age in the RemoteModuleBase. This is primarily useful for grpc connections which only poll dns once on creation. This means that if you add a downstream server (like Kubernetes HPA) to the DNS pool existing grpc channels won't "discover" the new replicas until the pod has been restarted.
Special notes for your reviewer:
If applicable: