outpost: fix 100% CPU Usage when not connected to websocket

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-23 18:38:47 +02:00
parent aca3a5c458
commit f6e1bfdfc8
3 changed files with 6 additions and 4 deletions

View File

@ -213,6 +213,6 @@ class UserViewSet(UsedByMixin, ModelViewSet):
return queryset return queryset
def filter_queryset(self, 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 self._filter_queryset_for_list(queryset)
return super().filter_queryset(queryset) return super().filter_queryset(queryset)

View File

@ -71,14 +71,12 @@ func (ac *APIController) Shutdown() {
func (ac *APIController) startWSHandler() { func (ac *APIController) startWSHandler() {
logger := ac.logger.WithField("loop", "ws-handler") logger := ac.logger.WithField("loop", "ws-handler")
for { for {
if !ac.wsConn.IsConnected() {
continue
}
var wsMsg websocketMessage var wsMsg websocketMessage
err := ac.wsConn.ReadJSON(&wsMsg) err := ac.wsConn.ReadJSON(&wsMsg)
if err != nil { if err != nil {
logger.WithError(err).Warning("ws write error, reconnecting") logger.WithError(err).Warning("ws write error, reconnecting")
ac.wsConn.CloseAndReconnect() ac.wsConn.CloseAndReconnect()
time.Sleep(time.Second * 5)
continue continue
} }
if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { if wsMsg.Instruction == WebsocketInstructionTriggerUpdate {

View File

@ -32,6 +32,10 @@ slug: "2021.7"
- root: subclass SessionMiddleware to set Secure and SameSite flag depending on context - root: subclass SessionMiddleware to set Secure and SameSite flag depending on context
- web: fix error when showing error message of request - 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 ## Upgrading
This release does not introduce any new requirements. This release does not introduce any new requirements.