Skip to content
Snippets Groups Projects
Commit 27344682 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[backend] Add job state (kill)

parent 78c1e61c
No related branches found
No related tags found
1 merge request!194Scheduler
...@@ -146,7 +146,7 @@ class Migration(migrations.Migration): ...@@ -146,7 +146,7 @@ class Migration(migrations.Migration):
name='Job', name='Job',
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('status', models.CharField(default=b'N', max_length=1, choices=[(b'N', b'Queued'), (b'P', b'Processing'), (b'C', b'Completed'), (b'F', b'Failed'), (b'S', b'Skipped'), (b'L', b'Cancelled')])), ('status', models.CharField(default=b'N', max_length=1, choices=[(b'N', b'Queued'), (b'P', b'Processing'), (b'C', b'Completed'), (b'F', b'Failed'), (b'S', b'Skipped'), (b'L', b'Cancelled'), (b'K', b'Kill')])),
('runnable_date', models.DateTimeField(null=True, blank=True)), ('runnable_date', models.DateTimeField(null=True, blank=True)),
('start_date', models.DateTimeField(null=True, blank=True)), ('start_date', models.DateTimeField(null=True, blank=True)),
('end_date', models.DateTimeField(null=True, blank=True)), ('end_date', models.DateTimeField(null=True, blank=True)),
...@@ -163,7 +163,7 @@ class Migration(migrations.Migration): ...@@ -163,7 +163,7 @@ class Migration(migrations.Migration):
('split_index', models.PositiveIntegerField()), ('split_index', models.PositiveIntegerField()),
('start_index', models.PositiveIntegerField(null=True)), ('start_index', models.PositiveIntegerField(null=True)),
('end_index', models.PositiveIntegerField(null=True)), ('end_index', models.PositiveIntegerField(null=True)),
('status', models.CharField(default=b'N', max_length=1, choices=[(b'N', b'Queued'), (b'P', b'Processing'), (b'C', b'Completed'), (b'F', b'Failed'), (b'S', b'Skipped'), (b'L', b'Cancelled')])), ('status', models.CharField(default=b'N', max_length=1, choices=[(b'N', b'Queued'), (b'P', b'Processing'), (b'C', b'Completed'), (b'F', b'Failed'), (b'S', b'Skipped'), (b'L', b'Cancelled'), (b'K', b'Kill')])),
('start_date', models.DateTimeField(null=True)), ('start_date', models.DateTimeField(null=True)),
('end_date', models.DateTimeField(null=True)), ('end_date', models.DateTimeField(null=True)),
('process_id', models.PositiveIntegerField(null=True)), ('process_id', models.PositiveIntegerField(null=True)),
......
...@@ -472,6 +472,7 @@ class Job(models.Model): ...@@ -472,6 +472,7 @@ class Job(models.Model):
FAILED = 'F' #Block.FAILED FAILED = 'F' #Block.FAILED
SKIPPED = 'S' #Block.SKIPPED SKIPPED = 'S' #Block.SKIPPED
CANCELLED = 'L' #Block.CANCELLED CANCELLED = 'L' #Block.CANCELLED
KILL = 'K' #Job was asked to be killed
STATUS = ( STATUS = (
(QUEUED, 'Queued'), (QUEUED, 'Queued'),
...@@ -701,7 +702,8 @@ class Job(models.Model): ...@@ -701,7 +702,8 @@ class Job(models.Model):
elif (Job.PROCESSING in split_statuses) or \ elif (Job.PROCESSING in split_statuses) or \
(Job.QUEUED in split_statuses and \ (Job.QUEUED in split_statuses and \
Job.COMPLETED in split_statuses): Job.COMPLETED in split_statuses) or \
(Job.KILL in split_statuses):
self.status = Job.PROCESSING self.status = Job.PROCESSING
elif all([s == Job.SKIPPED for s in split_statuses]): elif all([s == Job.SKIPPED for s in split_statuses]):
...@@ -925,8 +927,8 @@ class JobSplit(models.Model): ...@@ -925,8 +927,8 @@ class JobSplit(models.Model):
JobSplit.objects.select_for_update().filter(pk=self.pk) JobSplit.objects.select_for_update().filter(pk=self.pk)
# If this split is running, then wait # If this split is running, then wait
if self.status == Job.PROCESSING and (self.process_id is not None): if self.status == Job.PROCESSING:
self.status = Job.CANCELLED self.status = Job.KILL
self.save() self.save()
logger.info("Job split `%s' is currently processing. Waiting " \ logger.info("Job split `%s' is currently processing. Waiting " \
"for worker to cancel split remotely.", self) "for worker to cancel split remotely.", self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment