Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES/7315.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug where API process would miss heartbeats during long uploads.
20 changes: 19 additions & 1 deletion pulpcore/app/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from logging import getLogger
import os
import sys
import threading
import time

import click
import django
Expand All @@ -22,9 +24,18 @@


class PulpApiWorker(SyncWorker):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.heartbeat_thread = None

def notify(self):
super().notify()
self.heartbeat()

def _heartbeat_loop(self):
while self.alive:
self.heartbeat()
time.sleep(self.heartbeat_interval)

def heartbeat(self):
try:
Expand Down Expand Up @@ -76,6 +87,13 @@ def init_process(self):
logger.error(f"An API app with name {self.name} already exists in the database.")
exit(Arbiter.WORKER_BOOT_ERROR)

# Store heartbeat interval for the heartbeat thread
self.heartbeat_interval = settings.API_APP_TTL // 3

# Start heartbeat thread before entering the main loop
self.heartbeat_thread = threading.Thread(target=self._heartbeat_loop, daemon=True)
self.heartbeat_thread.start()

super().init_process()

def run(self):
Expand Down