From 3a9903a836a77abc3578cbe72061e8d385f50c8f Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 14 Jun 2023 11:45:58 -0400 Subject: [PATCH] Don't attempt session teardown if the session is expired (#3312) This avoids a situation where teardown results in an error due to the worker not accepting the connection (since the credentials are invalid). Teardown is a best-effort way to avoid sessions that have long lifetimes ending up having to wait for expiration before cleanup, but if we're near expiration it doesn't really matter. Fixes ICU-9633 --- internal/cmd/commands/connect/connect.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cmd/commands/connect/connect.go b/internal/cmd/commands/connect/connect.go index bb38f20648..741aa74619 100644 --- a/internal/cmd/commands/connect/connect.go +++ b/internal/cmd/commands/connect/connect.go @@ -621,7 +621,10 @@ func (c *Command) Run(args []string) (retCode int) { } } - if sendSessionCancel { + // Only send it if we should, and also if we're not after expiration, with a + // bit of buffer in case clocks are not quite the same between worker and + // this machine. + if sendSessionCancel && time.Now().Before(c.expiration.Add(-5*time.Minute)) { ctx, cancel := context.WithTimeout(context.Background(), sessionCancelTimeout) wsConn, err := c.getWsConn(ctx, workerAddr, transport) if err != nil {