def find_logged_in_instance(user_id): sessname = unique_sessname(user_id) try: sess_props = JBoxSessionProps(Compute.get_install_id(), sessname) return sess_props.get_instance_id() except JBoxDBItemNotFound: return None
def do_periodic_task(_mode): active_clusters = UserCluster.list_all_groupids() ParallelHousekeep.log_info("%d active clusters", len(active_clusters)) if len(active_clusters) == 0: return for cluster_id in active_clusters: sessname = UserCluster.sessname_for_cluster(cluster_id) try: sess_props = JBoxSessionProps(Compute.get_install_id(), sessname) if not sess_props.get_instance_id(): ParallelHousekeep.log_info( "Session (%s) corresponding to cluster (%s) not found. Terminating cluster.", sessname, cluster_id) ParallelHousekeep.terminate_or_delete_cluster(cluster_id) except JBoxDBItemNotFound: pass