@@ -157,7 +157,7 @@ def __init__(
157
157
keys = None ,
158
158
source = "" ,
159
159
cache_time = 300 ,
160
- error_holddown = 0 ,
160
+ ignore_errors_period = 0 ,
161
161
fileformat = "jwks" ,
162
162
keytype = "RSA" ,
163
163
keyusage = None ,
@@ -190,7 +190,8 @@ def __init__(
190
190
self .remote = False
191
191
self .local = False
192
192
self .cache_time = cache_time
193
- self .error_holddown = error_holddown
193
+ self .ignore_errors_period = ignore_errors_period
194
+ self .ignore_errors_until = None # UNIX timestamp of last error
194
195
self .time_out = 0
195
196
self .etag = ""
196
197
self .source = None
@@ -201,7 +202,6 @@ def __init__(
201
202
self .last_updated = 0
202
203
self .last_remote = None # HTTP Date of last remote update
203
204
self .last_local = None # UNIX timestamp of last local update
204
- self .last_error = None # UNIX timestamp of last error
205
205
206
206
if httpc :
207
207
self .httpc = httpc
@@ -369,15 +369,13 @@ def do_remote(self):
369
369
# if self.verify_ssl is not None:
370
370
# self.httpc_params["verify"] = self.verify_ssl
371
371
372
- if self .last_error :
373
- t = self .last_error + self .error_holddown
374
- if time .time () < t :
375
- LOGGER .warning (
376
- "Not reading remote JWKS from %s (in error holddown until %s)" ,
377
- self .source ,
378
- datetime .fromtimestamp (t ),
379
- )
380
- return False
372
+ if self .ignore_errors_until and time .time () < self .ignore_errors_until :
373
+ LOGGER .warning (
374
+ "Not reading remote JWKS from %s (in error holddown until %s)" ,
375
+ self .source ,
376
+ datetime .fromtimestamp (self .ignore_errors_until ),
377
+ )
378
+ return False
381
379
382
380
LOGGER .info ("Reading remote JWKS from %s" , self .source )
383
381
try :
@@ -404,7 +402,7 @@ def do_remote(self):
404
402
self .do_keys (self .imp_jwks ["keys" ])
405
403
except KeyError :
406
404
LOGGER .error ("No 'keys' keyword in JWKS" )
407
- self .last_error = time .time ()
405
+ self .ignore_errors_until = time .time () + self . ignore_errors_period
408
406
raise UpdateFailed (MALFORMED .format (self .source ))
409
407
410
408
if hasattr (_http_resp , "headers" ):
@@ -417,15 +415,13 @@ def do_remote(self):
417
415
418
416
else :
419
417
LOGGER .warning (
420
- "HTTP status %d reading remote JWKS from %s" ,
421
- _http_resp .status_code ,
422
- self .source ,
418
+ "HTTP status %d reading remote JWKS from %s" , _http_resp .status_code , self .source ,
423
419
)
424
- self .last_error = time .time ()
420
+ self .ignore_errors_until = time .time () + self . ignore_errors_period
425
421
raise UpdateFailed (REMOTE_FAILED .format (self .source , _http_resp .status_code ))
426
422
427
423
self .last_updated = time .time ()
428
- self .last_error = None
424
+ self .ignore_errors_until = None
429
425
return True
430
426
431
427
def _parse_remote_response (self , response ):
0 commit comments