diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 2f9c4caf..3bd39902 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index fd36a380..83eaf235 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -13298,11 +13298,6 @@ msgstr "Yedeklendi" msgid "Running" msgstr "Çalışıyor" -#: vmbackups/models.py:88 -msgctxt "backup run" -msgid "Started" -msgstr "Başlatıldı" - #: vmbackups/templates/vmbackups/policies.html:17 #: vmbackups/templates/vmbackups/policy.html:13 #, python-format @@ -13342,11 +13337,6 @@ msgstr "%(n)s yedeklendi" msgid "%(n)s running" msgstr "%(n)s çalışıyor" -#: vmbackups/views.py:360 -#, python-format -msgid "%(n)s started" -msgstr "%(n)s başlatıldı" - #: vmbackups/views.py:360 #, python-format msgid "%(n)s failed" @@ -13356,3 +13346,7 @@ msgstr "%(n)s başarısız" #, python-format msgid "%(n)s skipped" msgstr "%(n)s atlandı" + +#: vmbackups/models.py:15 +msgid "The job was cancelled" +msgstr "İş iptal edildi" diff --git a/locale/uk/LC_MESSAGES/django.mo b/locale/uk/LC_MESSAGES/django.mo index ed28d958..17654ecf 100644 Binary files a/locale/uk/LC_MESSAGES/django.mo and b/locale/uk/LC_MESSAGES/django.mo differ diff --git a/locale/uk/LC_MESSAGES/django.po b/locale/uk/LC_MESSAGES/django.po index d0049152..3791d39f 100644 --- a/locale/uk/LC_MESSAGES/django.po +++ b/locale/uk/LC_MESSAGES/django.po @@ -11375,11 +11375,6 @@ msgstr "Резервну копію створено" msgid "Running" msgstr "Виконується" -#: vmbackups/models.py:88 -msgctxt "backup run" -msgid "Started" -msgstr "Розпочато" - #: vmbackups/models.py:89 vmbackups/templates/vmbackups/policy.html:38 msgid "Skipped" msgstr "Пропущено" @@ -11987,11 +11982,6 @@ msgstr "Створено резервних копій: %(n)s" msgid "%(n)s running" msgstr "Виконується: %(n)s" -#: vmbackups/views.py:360 -#, python-format -msgid "%(n)s started" -msgstr "Запущено: %(n)s" - #: vmbackups/views.py:360 #, python-format msgid "%(n)s failed" @@ -13448,3 +13438,7 @@ msgstr "Локальний хост" #: webvirtcloud/settings.py:351 msgid "All interfaces" msgstr "Усі інтерфейси" + +#: vmbackups/models.py:15 +msgid "The job was cancelled" +msgstr "Завдання скасовано" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 06625c62..1432ed98 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index aa9ed8e3..084a41e2 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -12431,11 +12431,6 @@ msgstr "已备份" msgid "Running" msgstr "运行中" -#: vmbackups/models.py:88 -msgctxt "backup run" -msgid "Started" -msgstr "已开始" - #: vmbackups/templates/vmbackups/policies.html:17 #: vmbackups/templates/vmbackups/policy.html:13 #, python-format @@ -12474,11 +12469,6 @@ msgstr "%(n)s 台已备份" msgid "%(n)s running" msgstr "%(n)s 台运行中" -#: vmbackups/views.py:360 -#, python-format -msgid "%(n)s started" -msgstr "%(n)s 台已开始" - #: vmbackups/views.py:360 #, python-format msgid "%(n)s failed" @@ -12488,3 +12478,7 @@ msgstr "%(n)s 台失败" #, python-format msgid "%(n)s skipped" msgstr "%(n)s 台已跳过" + +#: vmbackups/models.py:15 +msgid "The job was cancelled" +msgstr "作业已取消" diff --git a/static/css/webvirtcloud.css b/static/css/webvirtcloud.css index 76012552..a6ae61e6 100644 --- a/static/css/webvirtcloud.css +++ b/static/css/webvirtcloud.css @@ -378,5 +378,7 @@ td .tag-more { .run-failed::after { content: "\00d7"; color: #fff; font-size: .75rem; font-weight: 700; line-height: 1; } .run-days .run-failed::after { font-size: .625rem; } .run-skipped { border-color: var(--bs-secondary-color); } -.run-running, .run-started { border-color: var(--bs-info); background: linear-gradient(90deg, var(--bs-info) 50%, transparent 50%); } +.run-running { border-color: var(--bs-info); background: linear-gradient(90deg, var(--bs-info) 50%, transparent 50%); } .run-none { background: var(--bs-secondary-bg); } +/* high contrast themes would drop the marks' colours, which carry their meaning */ +@media (forced-colors: active) { .run-mark { forced-color-adjust: none; } } diff --git a/vmbackups/apps.py b/vmbackups/apps.py index 61732f7e..232d1134 100644 --- a/vmbackups/apps.py +++ b/vmbackups/apps.py @@ -1,6 +1,17 @@ from django.apps import AppConfig +from django.db.models.signals import pre_delete + + +def keep_job_end(sender, instance, **kwargs): + from .models import BackupRun + + BackupRun.keep_job_end(instance) class VmbackupsConfig(AppConfig): name = "vmbackups" verbose_name = "Backups" + + def ready(self): + # the job history drops ended jobs (operations.worker.housekeeping); a schedule's run keeps how its job went + pre_delete.connect(keep_job_end, sender="operations.Operation") diff --git a/vmbackups/migrations/0011_run_keeps_job_end.py b/vmbackups/migrations/0011_run_keeps_job_end.py new file mode 100644 index 00000000..7fa5e8ed --- /dev/null +++ b/vmbackups/migrations/0011_run_keeps_job_end.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.18 on 2026-11-25 06:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('vmbackups', '0010_keep_weekly_monthly'), + ] + + operations = [ + migrations.AlterField( + model_name='backuprun', + name='state', + field=models.CharField(choices=[('submitted', 'submitted'), ('skipped', 'skipped'), ('failed', 'failed'), ('succeeded', 'succeeded')], max_length=16), + ), + ] diff --git a/vmbackups/models.py b/vmbackups/models.py index ec246986..d2dd0558 100644 --- a/vmbackups/models.py +++ b/vmbackups/models.py @@ -4,7 +4,7 @@ import uuid from django.conf import settings from django.db import models from django.utils.translation import gettext_lazy as _ -from django.utils.translation import pgettext_lazy +from django.utils.translation import gettext_noop from computes.models import Compute, Tag from instances.models import Instance @@ -12,6 +12,9 @@ from operations.models import Operation from vrtManager.backup import backup_prefix +JOB_CANCELLED = gettext_noop("The job was cancelled") + + class BackupTarget(models.Model): """Storage the backups go to: a pool on each compute that sees it.""" @@ -81,12 +84,11 @@ class BackupPolicy(models.Model): class BackupRun(models.Model): """A schedule's backup of one VM on one day: what it submitted, or why not.""" - SUBMITTED, SKIPPED, FAILED = "submitted", "skipped", "failed" - STATES = [(SUBMITTED, "submitted"), (SKIPPED, "skipped"), (FAILED, "failed")] - # what came of it, its job's end included (outcome) - SUCCEEDED, RUNNING, STARTED = "succeeded", "running", "started" - OUTCOMES = {SUCCEEDED: _("Backed up"), RUNNING: _("Running"), STARTED: pgettext_lazy("backup run", "Started"), FAILED: _("Failed"), - SKIPPED: _("Skipped")} + SUBMITTED, SKIPPED, FAILED, SUCCEEDED = "submitted", "skipped", "failed", "succeeded" + # succeeded and failed also once its job has ended and the job history drops the job (keep_job_end) + STATES = [(SUBMITTED, "submitted"), (SKIPPED, "skipped"), (FAILED, "failed"), (SUCCEEDED, "succeeded")] + RUNNING = "running" # what came of it, its job's end included (outcome) + OUTCOMES = {SUCCEEDED: _("Backed up"), RUNNING: _("Running"), FAILED: _("Failed"), SKIPPED: _("Skipped")} policy = models.ForeignKey(BackupPolicy, on_delete=models.CASCADE, related_name="runs") instance = models.ForeignKey(Instance, on_delete=models.CASCADE, related_name="backup_runs") @@ -101,11 +103,9 @@ class BackupRun(models.Model): @classmethod def outcome_of(cls, state, job_state): - """Skipped or failed; else as its job went, or started once the job is gone from the job history (None).""" + """Its state; a submitted run's as its job goes.""" if state != cls.SUBMITTED: return state - if job_state is None: - return cls.STARTED if job_state == Operation.SUCCEEDED: return cls.SUCCEEDED return cls.RUNNING if job_state in Operation.ACTIVE else cls.FAILED @@ -118,6 +118,25 @@ class BackupRun(models.Model): def outcome_label(self): return self.OUTCOMES[self.outcome] + @property + def reason(self): + """Why it did not back up: its note, else its job's error.""" + if self.note or not self.operation_id: + return self.note + if self.operation.state == Operation.CANCELLED and not self.operation.error: + from operations.utils import say # operations.utils imports the models + + return say(JOB_CANCELLED) + return self.operation.error + + @classmethod + def keep_job_end(cls, job): + """Its runs keep what the job came to, which is gone with the job.""" + for run in cls.objects.filter(operation=job, state=cls.SUBMITTED).select_related("operation"): + run.state = cls.SUCCEEDED if job.state == Operation.SUCCEEDED else cls.FAILED + run.note = run.reason + run.save(update_fields=["state", "note"]) + UUID_IN_NAME = re.compile(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}") diff --git a/vmbackups/templates/vmbackups/policies.html b/vmbackups/templates/vmbackups/policies.html index bf662955..60c8064d 100644 --- a/vmbackups/templates/vmbackups/policies.html +++ b/vmbackups/templates/vmbackups/policies.html @@ -21,7 +21,7 @@ {% for policy in policies %}