Skip to content

Commit 7000ff0

Browse files
committed
Add recurring handling of user, resource and vgrid map refresh to janitor.
Still pending removal of client initiated refresh triggers in vgridman backend.
1 parent d5b2230 commit 7000ff0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mig/lib/janitor.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
from mig.shared.pwcrypto import verify_reset_token
4444
from mig.shared.serial import load
4545
from mig.shared.userdb import default_db_path, load_user_dict
46+
from mig.shared.vgridaccess import get_resource_map, get_user_map, \
47+
get_vgrid_map, last_refresh, RESOURCES, USERS, VGRIDS
4648

4749
REMIND_REQ_DAYS = 5
4850
EXPIRE_REQ_DAYS = 30
@@ -493,7 +495,17 @@ def handle_cache_updates(configuration, now=None):
493495
now = time.time()
494496
handled = 0
495497
_logger.debug("handle pending cache updates")
496-
# TODO: actually handle vgrid/user/resource/... cache updates
498+
# NOTE: we use get_X_map here to throttle down and only refresh when needed
499+
user_map = get_user_map(configuration, caching=False)
500+
if last_refresh[USERS] > now:
501+
handled += 1
502+
if configuration.site_enable_resources:
503+
resource_map = get_resource_map(configuration, caching=False)
504+
if last_refresh[RESOURCES] > now:
505+
handled += 1
506+
vgrid_map = get_vgrid_map(configuration, caching=False)
507+
if last_refresh[VGRIDS] > now:
508+
handled += 1
497509
if handled > 0:
498510
_logger.info("handled %d pending cache updates" % handled)
499511
else:

0 commit comments

Comments
 (0)