1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix: the API verifies a backup and shows what was found; Docker's health check reads /healthz

The backups API had every backup action but Verify, and did not show a
backup's verified_at and damage: a script restoring through it got no sign
of a damaged chain. Docker's health check asked for the login page, so a
hung job worker left the container healthy; it now reads /healthz.
This commit is contained in:
catborise 2026-11-19 20:45:09 +03:00
parent fc6ad4e8ca
commit 7b23c75bf5
5 changed files with 42 additions and 6 deletions

View file

@ -2,6 +2,7 @@ from rest_framework import serializers
from computes.models import Compute
from instances.models import Instance
from operations.utils import words
from .models import Backup, BackupFile, BackupTarget
@ -15,13 +16,20 @@ class BackupFileSerializer(serializers.ModelSerializer):
class BackupSerializer(serializers.ModelSerializer):
target = serializers.SlugRelatedField(slug_field="name", read_only=True)
files = BackupFileSerializer(many=True, read_only=True)
# what a verification found wrong with it or, else, with the first backup it builds on (a restore reads
# those too); empty: nothing
damage = serializers.SerializerMethodField()
class Meta:
model = Backup
fields = ["uuid", "target", "instance", "vm_uuid", "vm_name", "compute_name", "created_at", "finished_at",
"state", "consistency", "size", "files", "operation"]
"state", "consistency", "size", "files", "operation", "verified_at", "damage"]
read_only_fields = fields
def get_damage(self, backup) -> str:
damaged = backup.damaged_in_chain()
return words(damaged.damage) if damaged else ""
class CreateBackupSerializer(serializers.Serializer):
instance = serializers.PrimaryKeyRelatedField(queryset=Instance.objects.all())