From ac380fe16d0c8659f32d01e26630fb70ae821305 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 11 Apr 2024 23:16:33 +0100 Subject: [PATCH] Make device key updates less verbose in the logs on cancelled contexts --- userapi/internal/cross_signing.go | 4 ++++ userapi/internal/key_api.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/userapi/internal/cross_signing.go b/userapi/internal/cross_signing.go index 3c336026..b2bba0a9 100644 --- a/userapi/internal/cross_signing.go +++ b/userapi/internal/cross_signing.go @@ -19,6 +19,7 @@ import ( "context" "crypto/ed25519" "database/sql" + "errors" "fmt" "strings" @@ -466,6 +467,9 @@ func (a *UserInternalAPI) crossSigningKeysFromDatabase( for targetUserID := range req.UserToDevices { keys, err := a.KeyDatabase.CrossSigningKeysForUser(ctx, targetUserID) if err != nil { + if errors.Is(err, context.Canceled) { + return + } logrus.WithError(err).Errorf("Failed to get cross-signing keys for user %q", targetUserID) continue } diff --git a/userapi/internal/key_api.go b/userapi/internal/key_api.go index 4370add2..7014b2ce 100644 --- a/userapi/internal/key_api.go +++ b/userapi/internal/key_api.go @@ -531,6 +531,9 @@ func (a *UserInternalAPI) queryRemoteKeysOnServer( for userID := range userIDsForAllDevices { err := a.Updater.ManualUpdate(context.Background(), spec.ServerName(serverName), userID) if err != nil { + if errors.Is(err, context.Canceled) { + return + } logrus.WithFields(logrus.Fields{ logrus.ErrorKey: err, "user_id": userID, @@ -544,6 +547,9 @@ func (a *UserInternalAPI) queryRemoteKeysOnServer( // user so the fact that we're populating all devices here isn't a problem so long as we have devices. err = a.populateResponseWithDeviceKeysFromDatabase(ctx, res, respMu, userID, nil) if err != nil { + if errors.Is(err, context.Canceled) { + return + } logrus.WithFields(logrus.Fields{ logrus.ErrorKey: err, "user_id": userID,