mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
feat(operations): job, claim and worker lease models
This commit is contained in:
parent
5f8f7a8643
commit
99b9aa2a3c
9 changed files with 305 additions and 0 deletions
150
operations/migrations/0001_initial.py
Normal file
150
operations/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
# Generated by Django 5.2.18 on 2026-10-13 13:58
|
||||
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="WorkerLease",
|
||||
fields=[
|
||||
(
|
||||
"name",
|
||||
models.CharField(
|
||||
default="worker",
|
||||
max_length=16,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("holder", models.CharField(max_length=128)),
|
||||
("host", models.CharField(max_length=255)),
|
||||
("heartbeat_at", models.DateTimeField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Operation",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("kind", models.CharField(db_index=True, max_length=64)),
|
||||
("username", models.CharField(max_length=150)),
|
||||
("submission_key", models.CharField(max_length=64)),
|
||||
("resource", models.CharField(db_index=True, max_length=255)),
|
||||
("resource_label", models.CharField(max_length=255)),
|
||||
(
|
||||
"state",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("queued", "queued"),
|
||||
("running", "running"),
|
||||
("cancelling", "cancelling"),
|
||||
("succeeded", "succeeded"),
|
||||
("failed", "failed"),
|
||||
("cancelled", "cancelled"),
|
||||
("uncertain", "uncertain"),
|
||||
],
|
||||
db_index=True,
|
||||
default="queued",
|
||||
max_length=16,
|
||||
),
|
||||
),
|
||||
("params", models.JSONField(default=dict)),
|
||||
("intent", models.JSONField(default=dict)),
|
||||
("effects_started", models.BooleanField(default=False)),
|
||||
("phase", models.CharField(blank=True, max_length=255)),
|
||||
("progress_done", models.BigIntegerField(null=True)),
|
||||
("progress_total", models.BigIntegerField(null=True)),
|
||||
("result", models.JSONField(default=dict)),
|
||||
("error", models.TextField(blank=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
|
||||
("started_at", models.DateTimeField(null=True)),
|
||||
("finished_at", models.DateTimeField(null=True)),
|
||||
("heartbeat_at", models.DateTimeField(null=True)),
|
||||
("worker", models.CharField(blank=True, max_length=128)),
|
||||
("time_limit", models.PositiveIntegerField(null=True)),
|
||||
("cancel_requested", models.BooleanField(default=False)),
|
||||
("resolved_at", models.DateTimeField(null=True)),
|
||||
("resolution", models.CharField(blank=True, max_length=16)),
|
||||
("resolution_note", models.TextField(blank=True)),
|
||||
(
|
||||
"resolved_by",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="+",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"user",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="operations",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["-created_at"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Claim",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("resource", models.CharField(db_index=True, max_length=255)),
|
||||
(
|
||||
"mode",
|
||||
models.CharField(
|
||||
choices=[("shared", "shared"), ("exclusive", "exclusive")],
|
||||
max_length=9,
|
||||
),
|
||||
),
|
||||
("holder", models.CharField(blank=True, max_length=128)),
|
||||
("expires_at", models.DateTimeField(null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
"operation",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="claims",
|
||||
to="operations.operation",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="operation",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("user", "submission_key"), name="unique_submission"
|
||||
),
|
||||
),
|
||||
]
|
||||
0
operations/migrations/__init__.py
Normal file
0
operations/migrations/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue