Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust logging for cache debug #603

Merged
merged 2 commits into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions api/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,24 @@ def has_expired(username) -> bool:
has_expired = True
# Expired, reset the expiry time
CachedContent._timers[username] = now + CachedContent._cache_period
if has_expired:
logger.info("Content expired for '%s'", username)
return has_expired

@staticmethod
def get_content(username):
with CachedContent._cache_lock:
if username not in CachedContent._content:
CachedContent._content[username] = []
return CachedContent._content[username]
CachedContent._content[username] = set()
content = CachedContent._content[username]
logger.info("Got content for '%s': %s", username, content)
return content

@staticmethod
def set_content(username, content) -> None:
with CachedContent._cache_lock:
CachedContent._content[username] = content.copy()
logger.info("Set content for '%s': %s", username, content)


def get_remote_conn(force_error_display=False) -> Optional[SSHConnector]:
Expand Down Expand Up @@ -244,7 +249,7 @@ def _get_proposals_for_user_from_ispyb(self, user):
logger.info("Cache has expired for '%s'", user.username)
PrometheusMetrics.new_proposal_cache_miss()
if conn := get_configured_connector():
logger.debug("Got a connector for '%s'", user.username)
logger.info("Got a connector for '%s'", user.username)
self._get_proposals_from_connector(user, conn)
else:
logger.warning("Failed to get a connector for '%s'", user.username)
Expand Down Expand Up @@ -315,9 +320,9 @@ def _get_proposals_from_connector(self, user, conn):
proposal_visit_str = f'{proposal_str}-{sn_str}'
prop_id_set.update([proposal_str, proposal_visit_str])

# Always display the collected results for the user.
# Display the collected results for the user.
# These will be cached.
logger.debug(
logger.info(
"%s proposals from %s records for '%s': %s",
len(prop_id_set),
len(rs),
Expand Down