From e7da195645199b71ed995eac60190edab03a5f4c Mon Sep 17 00:00:00 2001 From: TLSM Date: Thu, 13 Oct 2022 02:12:35 -0400 Subject: [PATCH] Revert "Disable Cloudflare API call timing out admin_home." This reverts commit ed27225d10a998d570dbb3c8a8b8bcf23d45d851. The proximal cause of the request timeout issues was the /comments performance issues, which seem to have been resolved by 2edeb4875. Probably still need to refactor this, but for now it's likely fine. --- files/routes/admin.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index d3403894c..f7671134b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -425,14 +425,10 @@ def reported_comments(v): def admin_home(v): under_attack = False - ### TODO: This is timing out in gevent, something to do with _SSLErrorReadTimeout. - ### For some reason it manages to take down all the workers in the process. - ### Major service disruptions. Non-essential, so will resolve later. [2022-10-13] - ### TODO: Make more robust to API outages/timeouts. And move to a helper. - #if v.admin_level >= PERMS['SITE_SETTINGS_UNDER_ATTACK']: - # if CF_ZONE == 'blahblahblah': response = 'high' - # else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value'] - # under_attack = response == 'under_attack' + if v.admin_level >= PERMS['SITE_SETTINGS_UNDER_ATTACK']: + if CF_ZONE == 'blahblahblah': response = 'high' + else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value'] + under_attack = response == 'under_attack' gitref = admin_git_head()