Skip to content

Commit

Permalink
oneclick: Do not use a stale Zulip client.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexmv authored and timabbott committed May 17, 2022
1 parent c341414 commit ff647df
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
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"


Expand Down Expand Up @@ -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__":
Expand Down

0 comments on commit ff647df

Please sign in to comment.