mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(operations): jobs a request runs
Request jobs (an upload's chunks) run in gunicorn: their kind is admitted running with the request as its worker, never claimed or recovered by the worker, cancelled in the request, and asked by every housekeeping pass to end its jobs that went idle. The panel can follow a job the page just started. A job a request runs does not wait for the worker, so it does not raise the worker-unavailable warning on the Jobs page or in the panel.
This commit is contained in:
parent
41e1fcd4b9
commit
f2138e54d8
14 changed files with 224 additions and 17 deletions
|
|
@ -26,6 +26,7 @@ class Operation(models.Model):
|
|||
ACTIVE = (QUEUED, RUNNING, CANCELLING)
|
||||
TERMINAL = (SUCCEEDED, FAILED, CANCELLED, UNCERTAIN)
|
||||
STATES = [(s, s) for s in ACTIVE + TERMINAL]
|
||||
REQUEST = "request" # the worker of a job a request runs
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
kind = models.CharField(max_length=64, db_index=True)
|
||||
|
|
@ -49,7 +50,8 @@ class Operation(models.Model):
|
|||
started_at = models.DateTimeField(null=True)
|
||||
finished_at = models.DateTimeField(null=True)
|
||||
heartbeat_at = models.DateTimeField(null=True)
|
||||
worker = models.CharField(max_length=128, blank=True) # identity of the worker that owns it
|
||||
# identity of the owning worker; REQUEST for a job a request runs, which the worker never claims or recovers
|
||||
worker = models.CharField(max_length=128, blank=True)
|
||||
time_limit = models.PositiveIntegerField(null=True) # seconds, fixed at admission
|
||||
cancel_requested = models.BooleanField(default=False)
|
||||
resolved_by = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL, related_name="+")
|
||||
|
|
@ -64,6 +66,10 @@ class Operation(models.Model):
|
|||
def __str__(self):
|
||||
return f"{self.kind} {self.id}"
|
||||
|
||||
@property
|
||||
def in_request(self):
|
||||
return self.worker == Operation.REQUEST
|
||||
|
||||
|
||||
class Claim(models.Model):
|
||||
SHARED = "shared"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue