Skip to content

Commit

Permalink
health
Browse files Browse the repository at this point in the history
  • Loading branch information
NotChristianGarcia committed Oct 29, 2024
1 parent fc4d925 commit 1a896dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kubernetes==28.1.0
neo4j-driver
rabbitpy
channelpy
python-multipart

# Misc
pylint
Expand Down
37 changes: 22 additions & 15 deletions service/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,34 +86,41 @@ def rm_volume(k8_name):

return volume_exists

def graceful_rm_pod(pod, log = None):
def graceful_rm_pod(pod, log=None):
"""
This is async. Commands run, but deletion takes some time.
Needs to delete pod, delete service, and change traefik to "offline" response.
TODO Set status to shutting down. Something else will put into "STOPPED".
"""
logger.info(f"Top of shutdown pod for pod: {pod.k8_name}")
# Change pod status to SHUTTING DOWN
pod.status = DELETING
pod.db_update(log)
logger.debug(f"spawner has updated pod status to DELETING")
try:
logger.info(f"Top of shutdown pod for pod: {pod.k8_name}")
# Change pod status to SHUTTING DOWN
pod.status = DELETING
pod.db_update(log)
logger.debug(f"spawner has updated pod status to DELETING")

return rm_pod(pod.k8_name)
return rm_pod(pod.k8_name)
except Exception as e:
logger.error(f"Failed to gracefully remove pod {pod.k8_name}: {e}")
raise

def graceful_rm_volume(volume):
"""
This is async. Commands run, but deletion takes some time.
Needs to delete volume, delete volume, and change traefik to "offline" response.
TODO Set status to shutting down. Something else will put into "STOPPED".
"""
logger.info(f"Top of shutdown volume for volume: {volume.k8_name}")
# Change pod status to SHUTTING DOWN
volume.status = DELETING
volume.db_update()
logger.debug(f"spawner has updated volume status to DELETING")

return rm_volume(volume.k8_name)

try:
logger.info(f"Top of shutdown volume for volume: {volume.k8_name}")
# Change volume status to SHUTTING DOWN
volume.status = DELETING
volume.db_update()
logger.debug(f"spawner has updated volume status to DELETING")

return rm_volume(volume.k8_name)
except Exception as e:
logger.error(f"Failed to gracefully remove volume {volume.k8_name}: {e}")
raise
def check_k8_pods(k8_pods):
"""
Check the health of Kubernetes pods.
Expand Down

0 comments on commit 1a896dc

Please sign in to comment.