From f6e1bfdfc85530dfe3dbae945910975414f2cb83 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 23 Jul 2021 18:38:47 +0200 Subject: [PATCH] outpost: fix 100% CPU Usage when not connected to websocket Signed-off-by: Jens Langhammer --- authentik/core/api/users.py | 2 +- internal/outpost/ak/api_ws.go | 4 +--- website/docs/releases/v2021.7.md | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index a3733e65e..6593fb937 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -213,6 +213,6 @@ class UserViewSet(UsedByMixin, ModelViewSet): return queryset def filter_queryset(self, queryset): - if self.request.user.has_perm("authentik_core.view_group"): + if self.request.user.has_perm("authentik_core.view_user"): return self._filter_queryset_for_list(queryset) return super().filter_queryset(queryset) diff --git a/internal/outpost/ak/api_ws.go b/internal/outpost/ak/api_ws.go index 68f8011f1..767f032fa 100644 --- a/internal/outpost/ak/api_ws.go +++ b/internal/outpost/ak/api_ws.go @@ -71,14 +71,12 @@ func (ac *APIController) Shutdown() { func (ac *APIController) startWSHandler() { logger := ac.logger.WithField("loop", "ws-handler") for { - if !ac.wsConn.IsConnected() { - continue - } var wsMsg websocketMessage err := ac.wsConn.ReadJSON(&wsMsg) if err != nil { logger.WithError(err).Warning("ws write error, reconnecting") ac.wsConn.CloseAndReconnect() + time.Sleep(time.Second * 5) continue } if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { diff --git a/website/docs/releases/v2021.7.md b/website/docs/releases/v2021.7.md index 25f4044bb..84224b7fe 100644 --- a/website/docs/releases/v2021.7.md +++ b/website/docs/releases/v2021.7.md @@ -32,6 +32,10 @@ slug: "2021.7" - root: subclass SessionMiddleware to set Secure and SameSite flag depending on context - web: fix error when showing error message of request +## Fixed in 2021.7.1-rc2 + +- outpost: fix 100% CPU Usage when not connected to websocket + ## Upgrading This release does not introduce any new requirements.