From ff647dff03f178c329240c0e938d3fff8fbc5ab0 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 12 May 2022 03:19:07 -0700 Subject: [PATCH] oneclick: Do not use a stale Zulip client. Initializing the Zulip client opens a long-lived TCP connection due to connection pooling in urllib3. In Github Actions, the network kills such requests after ~270s, making the later `send_message` call fail. Use a singular call to `zulip.Client()` early on to verify the credentials, and do not cache the resulting client object. Instead, re-create it during the final step when it is needed, so we do not run afoul of bad TCP connection state. This would ideally be fixed via connection keepalive or retry at the level of the Zulip module. --- .../prepare_digital_ocean_one_click_app_release.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/oneclickapps/prepare_digital_ocean_one_click_app_release.py b/tools/oneclickapps/prepare_digital_ocean_one_click_app_release.py index be5a48c830..c3ead4315e 100644 --- a/tools/oneclickapps/prepare_digital_ocean_one_click_app_release.py +++ b/tools/oneclickapps/prepare_digital_ocean_one_click_app_release.py @@ -10,7 +10,10 @@ from requests.adapters import HTTPAdapter from urllib3.util import Retry manager = digitalocean.Manager(token=os.environ["DIGITALOCEAN_API_KEY"]) -zulip_client = zulip.Client() +# We just temporarily create the client now, to validate that we can +# auth to the server; reusing it after the whole install fails because +# the connection has been half-closed in a way that breaks it. +zulip.Client() TEST_DROPLET_SUBDOMAIN = "do" @@ -126,7 +129,7 @@ def send_message(content: str) -> None: "topic": "digitalocean installer", "content": content, } - zulip_client.send_message(request) + zulip.Client().send_message(request) if __name__ == "__main__":