Conversation
c313a9a to
b99e67c
Compare
pulpcore/app/entrypoint.py
Outdated
| self.heartbeat() | ||
|
|
||
| def _heartbeat_loop(self): | ||
| while self.alive: |
There was a problem hiding this comment.
A gunicorn SyncWorker sets self.alive to False during graceful shutdown. This ensures that when a graceful shutdown is requested, the thread does not make another heartbeat update. This check is not critical, because the thread will be shut down soon anyway.
pulpcore/app/entrypoint.py
Outdated
| super().notify() | ||
| self.heartbeat() | ||
|
|
||
| def _heartbeat_loop(self): |
There was a problem hiding this comment.
What happens if the thread dies?
There was a problem hiding this comment.
I am going to add logic to handle the thread dying.
| super().__init__(*args, **kwargs) | ||
| self.heartbeat_thread = None | ||
|
|
||
| def notify(self): |
There was a problem hiding this comment.
First i thought, this is dead code. Now i think we have the opportunity to check in on the thread here.
| # Store heartbeat interval for the heartbeat thread | ||
| self.heartbeat_interval = settings.API_APP_TTL // 3 | ||
|
|
||
| # Start heartbeat thread before entering the main loop |
There was a problem hiding this comment.
Now why don't we then put all of that stuff right before entering the main loop?
| name_template = name_template_var.get() | ||
| if name_template: | ||
| settings.set("WORKER_NAME_TEMPLATE", name_template) | ||
| if settings.API_APP_TTL < 2 * self.timeout: |
There was a problem hiding this comment.
Did you never get to see this warning?
There was a problem hiding this comment.
i've only seen this warning on my dev environment.
| 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 |
There was a problem hiding this comment.
| # Store heartbeat interval for the heartbeat thread | |
| # Store the value of one third of the desired API application's time to live to the heartbeat interval on the current instance to be accessible by the heartbeat thread. |
:mild sarcasm:
fixes: #7315
📜 Checklist
See: Pull Request Walkthrough